int jabber_si_check_features(struct jabber_transfer *tf, GSList *features) { int foundft = FALSE, foundbt = FALSE, foundsi = FALSE; while (features) { if (!strcmp(features->data, XMLNS_FILETRANSFER)) { foundft = TRUE; } if (!strcmp(features->data, XMLNS_BYTESTREAMS)) { foundbt = TRUE; } if (!strcmp(features->data, XMLNS_SI)) { foundsi = TRUE; } features = g_slist_next(features); } if (!foundft) { imcb_file_canceled(tf->ic, tf->ft, "Buddy's client doesn't feature file transfers"); } else if (!foundbt) { imcb_file_canceled(tf->ic, tf->ft, "Buddy's client doesn't feature byte streams (required)"); } else if (!foundsi) { imcb_file_canceled(tf->ic, tf->ft, "Buddy's client doesn't feature stream initiation (required)"); } return foundft && foundbt && foundsi; }
void jabber_si_transfer_request(struct im_connection *ic, file_transfer_t *ft, char *who) { struct jabber_transfer *tf; struct jabber_data *jd = ic->proto_data; struct jabber_buddy *bud; char *server = jd->server, *s; if ((s = strchr(who, '=')) && jabber_chat_by_jid(ic, s + 1)) { bud = jabber_buddy_by_ext_jid(ic, who, 0); } else { bud = jabber_buddy_by_jid(ic, who, 0); } if (bud == NULL) { imcb_file_canceled(ic, ft, "Couldn't find buddy (BUG?)"); return; } imcb_log(ic, "Trying to send %s(%zd bytes) to %s", ft->file_name, ft->file_size, who); tf = g_new0(struct jabber_transfer, 1); tf->ic = ic; tf->ft = ft; tf->fd = -1; tf->ft->data = tf; tf->ft->free = jabber_si_free_transfer; tf->bud = bud; ft->write = jabber_bs_send_write; jd->filetransfers = g_slist_prepend(jd->filetransfers, tf); /* query buddy's features and server's streaming proxies if necessary */ if (!tf->bud->features) { jabber_iq_query_features(ic, bud->full_jid); } /* If <auto> is not set don't check for proxies */ if ((jd->have_streamhosts != 1) && (jd->streamhosts == NULL) && (strstr(set_getstr(&ic->acc->set, "proxy"), "<auto>") != NULL)) { jd->have_streamhosts = 0; jabber_iq_query_server(ic, server, XMLNS_DISCO_ITEMS); } else if (jd->streamhosts != NULL) { jd->have_streamhosts = 1; } /* if we had to do a query, wait for the result. * Otherwise fire away. */ if (!tf->bud->features || jd->have_streamhosts != 1) { tf->disco_timeout = b_timeout_add(500, jabber_si_waitfor_disco, tf); } else { jabber_si_transfer_start(tf); } }
/* * Vararg wrapper for imcb_file_canceled(). */ gboolean msn_ftp_abort( file_transfer_t *file, char *format, ... ) { va_list params; va_start( params, format ); char error[128]; if( vsnprintf( error, 128, format, params ) < 0 ) sprintf( error, "internal error parsing error string (BUG)" ); va_end( params ); imcb_file_canceled( file, error ); return FALSE; }
static void jabber_logout( struct im_connection *ic ) { struct jabber_data *jd = ic->proto_data; while( jd->filetransfers ) imcb_file_canceled( ic, ( ( struct jabber_transfer *) jd->filetransfers->data )->ft, "Logging out" ); while( jd->streamhosts ) { jabber_streamhost_t *sh = jd->streamhosts->data; jd->streamhosts = g_slist_remove( jd->streamhosts, sh ); g_free( sh->jid ); g_free( sh->host ); g_free( sh ); } if( jd->fd >= 0 ) jabber_end_stream( ic ); while( ic->groupchats ) jabber_chat_free( ic->groupchats->data ); if( jd->r_inpa >= 0 ) b_event_remove( jd->r_inpa ); if( jd->w_inpa >= 0 ) b_event_remove( jd->w_inpa ); if( jd->ssl ) ssl_disconnect( jd->ssl ); if( jd->fd >= 0 ) closesocket( jd->fd ); if( jd->tx_len ) g_free( jd->txq ); if( jd->node_cache ) g_hash_table_destroy( jd->node_cache ); jabber_buddy_remove_all( ic ); xt_free( jd->xt ); g_free( jd->oauth2_access_token ); g_free( jd->away_message ); g_free( jd->username ); g_free( jd->me ); g_free( jd ); jabber_connections = g_slist_remove( jabber_connections, ic ); }
static void jabber_logout(struct im_connection *ic) { struct jabber_data *jd = ic->proto_data; while (jd->filetransfers) { imcb_file_canceled(ic, (( struct jabber_transfer *) jd->filetransfers->data)->ft, "Logging out"); } while (jd->streamhosts) { jabber_streamhost_t *sh = jd->streamhosts->data; jd->streamhosts = g_slist_remove(jd->streamhosts, sh); g_free(sh->jid); g_free(sh->host); g_free(sh); } if (jd->fd >= 0) { jabber_end_stream(ic); } while (ic->groupchats) { jabber_chat_free(ic->groupchats->data); } if (jd->r_inpa >= 0) { b_event_remove(jd->r_inpa); } if (jd->w_inpa >= 0) { b_event_remove(jd->w_inpa); } if (jd->ssl) { ssl_disconnect(jd->ssl); } if (jd->fd >= 0) { proxy_disconnect(jd->fd); } if (jd->tx_len) { g_free(jd->txq); } if (jd->node_cache) { g_hash_table_destroy(jd->node_cache); } if (jd->buddies) { jabber_buddy_remove_all(ic); } xt_free(jd->xt); md5_free(&jd->cached_id_prefix); g_free(jd->oauth2_access_token); g_free(jd->away_message); g_free(jd->internal_jid); g_free(jd->gmail_tid); g_free(jd->muc_host); g_free(jd->username); g_free(jd->me); g_free(jd); jabber_connections = g_slist_remove(jabber_connections, ic); }