PurpleXfer *yahoo_new_xfer(PurpleConnection *gc, const char *who) { PurpleXfer *xfer; struct yahoo_xfer_data *xfer_data; g_return_val_if_fail(who != NULL, NULL); xfer_data = g_new0(struct yahoo_xfer_data, 1); xfer_data->gc = gc; /* Build the file transfer handle. */ xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); if (xfer) { xfer->data = xfer_data; /* Setup our I/O op functions */ purple_xfer_set_init_fnc(xfer, yahoo_xfer_init); purple_xfer_set_start_fnc(xfer, yahoo_xfer_start); purple_xfer_set_end_fnc(xfer, yahoo_xfer_end); purple_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send); purple_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv); purple_xfer_set_read_fnc(xfer, yahoo_xfer_read); purple_xfer_set_write_fnc(xfer, yahoo_xfer_write); } return xfer; }
PurpleXfer *sipe_purple_ft_new_xfer(PurpleConnection *gc, const char *who) { PurpleXfer *xfer = NULL; if (PURPLE_CONNECTION_IS_VALID(gc)) { xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_SEND, who); if (xfer) { struct sipe_file_transfer *ft = sipe_core_ft_allocate(PURPLE_GC_TO_SIPE_CORE_PUBLIC); ft->backend_private = (struct sipe_backend_file_transfer *)xfer; PURPLE_XFER_DATA = ft; purple_xfer_set_init_fnc(xfer, ft_outgoing_init); purple_xfer_set_request_denied_fnc(xfer, ft_request_denied); purple_xfer_set_cancel_send_fnc(xfer, ft_free_xfer_struct); purple_xfer_set_cancel_recv_fnc(xfer, ft_free_xfer_struct); purple_xfer_set_start_fnc(xfer, tftp_outgoing_start); purple_xfer_set_end_fnc(xfer, tftp_outgoing_stop); purple_xfer_set_write_fnc(xfer, tftp_write); } } return xfer; }
void msn_request_ft(PurpleXfer *xfer) { MsnSlpCall *slpcall; MsnSlpLink *slplink; char *context; const char *fn; const char *fp; fn = purple_xfer_get_filename(xfer); fp = purple_xfer_get_local_filename(xfer); slplink = purple_xfer_get_protocol_data(xfer); g_return_if_fail(slplink != NULL); g_return_if_fail(fp != NULL); slpcall = msn_slpcall_new(slplink); msn_slpcall_init(slpcall, MSN_SLPCALL_DC); slpcall->session_init_cb = send_file_cb; slpcall->end_cb = msn_xfer_end_cb; slpcall->cb = msn_xfer_completed_cb; slpcall->xfer = xfer; g_object_ref(slpcall->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); purple_xfer_set_protocol_data(xfer, slpcall); context = gen_context(xfer, fn, fp); msn_slpcall_invite(slpcall, MSN_FT_GUID, P2P_APPID_FILE, context); msn_slplink_unref(slplink); g_free(context); }
PurpleXfer *irc_dccsend_new_xfer(PurpleConnection *gc, const char *who) { PurpleXfer *xfer; struct irc_xfer_send_data *xd; /* Build the file transfer handle */ xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_SEND, who); if (xfer) { xd = g_new0(struct irc_xfer_send_data, 1); xd->fd = -1; xfer->data = xd; /* Setup our I/O op functions */ purple_xfer_set_init_fnc(xfer, irc_dccsend_send_init); purple_xfer_set_write_fnc(xfer, irc_dccsend_send_write); purple_xfer_set_end_fnc(xfer, irc_dccsend_send_destroy); purple_xfer_set_request_denied_fnc(xfer, irc_dccsend_send_destroy); purple_xfer_set_cancel_send_fnc(xfer, irc_dccsend_send_destroy); } return xfer; }
/*------------------------------------------------------------------------ * Create and initialize a new file transfer to a contact. * * @param gc The connection object * @param who The username of the recipient */ PurpleXfer* mxit_xfer_new( PurpleConnection* gc, const char* who ) { struct MXitSession* session = (struct MXitSession*) gc->proto_data; PurpleXfer* xfer = NULL; struct mxitxfer* mx = NULL; /* (reference: "libpurple/ft.h") */ xfer = purple_xfer_new( session->acc, PURPLE_XFER_SEND, who ); /* create file info and attach it to the file transfer */ mx = g_new0( struct mxitxfer, 1 ); mx->session = session; xfer->data = mx; /* configure callbacks (reference: "libpurple/ft.h") */ purple_xfer_set_init_fnc( xfer, mxit_xfer_init ); purple_xfer_set_start_fnc( xfer, mxit_xfer_start ); purple_xfer_set_end_fnc( xfer, mxit_xfer_end ); purple_xfer_set_cancel_send_fnc( xfer, mxit_xfer_cancel_send ); purple_xfer_set_write_fnc( xfer, mxit_xfer_write ); return xfer; }
PurpleXfer * skypeweb_new_xfer(PurpleConnection *pc, const char *who) { SkypeWebAccount *sa = purple_connection_get_protocol_data(pc); PurpleXfer *xfer; SkypeWebFileTransfer *swft; xfer = purple_xfer_new(sa->account, PURPLE_XFER_SEND, who); swft = g_new0(SkypeWebFileTransfer, 1); swft->sa = sa; swft->from = g_strdup(who); swft->xfer = xfer; purple_xfer_set_protocol_data(xfer, swft); purple_xfer_set_init_fnc(xfer, skypeweb_xfer_send_init); purple_xfer_set_write_fnc(xfer, skypeweb_xfer_send_write); purple_xfer_set_end_fnc(xfer, skypeweb_free_xfer); purple_xfer_set_request_denied_fnc(xfer, skypeweb_free_xfer); purple_xfer_set_cancel_send_fnc(xfer, skypeweb_free_xfer); return xfer; }
void yahoo_process_filetransfer(PurpleConnection *gc, struct yahoo_packet *pkt) { char *from = NULL; char *to = NULL; char *msg = NULL; char *url = NULL; char *imv = NULL; long expires = 0; PurpleXfer *xfer; struct yahoo_data *yd; struct yahoo_xfer_data *xfer_data; char *service = NULL; char *filename = NULL; unsigned long filesize = 0L; GSList *l; yd = gc->proto_data; for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; if (pair->key == 4) from = pair->value; if (pair->key == 5) to = pair->value; if (pair->key == 14) msg = pair->value; if (pair->key == 20) url = pair->value; if (pair->key == 38) expires = strtol(pair->value, NULL, 10); if (pair->key == 27) filename = pair->value; if (pair->key == 28) filesize = atol(pair->value); if (pair->key == 49) service = pair->value; if (pair->key == 63) imv = pair->value; } /* * The remote user has changed their IMVironment. We * record it for later use. */ if (from && imv && service && (strcmp("IMVIRONMENT", service) == 0)) { g_hash_table_replace(yd->imvironments, g_strdup(from), g_strdup(imv)); return; } if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) { if (service && (strcmp("FILEXFER", service) != 0)) { purple_debug_misc("yahoo", "unhandled service 0x%02x\n", pkt->service); return; } } if (msg) { char *tmp; tmp = strchr(msg, '\006'); if (tmp) *tmp = '\0'; } if (!url || !from) return; /* Setup the Yahoo-specific file transfer data */ xfer_data = g_new0(struct yahoo_xfer_data, 1); xfer_data->gc = gc; if (!purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL)) { g_free(xfer_data); return; } purple_debug_misc("yahoo_filexfer", "Host is %s, port is %d, path is %s, and the full url was %s.\n", xfer_data->host, xfer_data->port, xfer_data->path, url); /* Build the file transfer handle. */ xfer = purple_xfer_new(gc->account, PURPLE_XFER_RECEIVE, from); if (xfer) { xfer->data = xfer_data; /* Set the info about the incoming file. */ if (filename) { char *utf8_filename = yahoo_string_decode(gc, filename, TRUE); purple_xfer_set_filename(xfer, utf8_filename); g_free(utf8_filename); } else { gchar *start, *end; start = g_strrstr(xfer_data->path, "/"); if (start) start++; end = g_strrstr(xfer_data->path, "?"); if (start && *start && end) { char *utf8_filename; filename = g_strndup(start, end - start); utf8_filename = yahoo_string_decode(gc, filename, TRUE); g_free(filename); purple_xfer_set_filename(xfer, utf8_filename); g_free(utf8_filename); filename = NULL; } } purple_xfer_set_size(xfer, filesize); /* Setup our I/O op functions */ purple_xfer_set_init_fnc(xfer, yahoo_xfer_init); purple_xfer_set_start_fnc(xfer, yahoo_xfer_start); purple_xfer_set_end_fnc(xfer, yahoo_xfer_end); purple_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send); purple_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv); purple_xfer_set_read_fnc(xfer, yahoo_xfer_read); purple_xfer_set_write_fnc(xfer, yahoo_xfer_write); /* Now perform the request */ purple_xfer_request(xfer); } }