Mercurial > pidgin
comparison libpurple/protocols/yahoo/yahoo_filexfer.c @ 25065:d96190de653a
Add + in place of spaces in p2p url, fixes transfer of file with name containing spaces
author | Sulabh Mahajan <sulabh@soc.pidgin.im> |
---|---|
date | Wed, 09 Jul 2008 18:19:37 +0000 |
parents | 2fb8c39d0494 |
children | 37b207e08c69 |
comparison
equal
deleted
inserted
replaced
25064:2fb8c39d0494 | 25065:d96190de653a |
---|---|
1328 return; | 1328 return; |
1329 } | 1329 } |
1330 | 1330 |
1331 url_head = g_strdup_printf("HEAD %s", xd->xfer_url); | 1331 url_head = g_strdup_printf("HEAD %s", xd->xfer_url); |
1332 url_get = g_strdup_printf("GET %s", xd->xfer_url); | 1332 url_get = g_strdup_printf("GET %s", xd->xfer_url); |
1333 | 1333 |
1334 if( strncmp(url_head, (char *)buf, strlen(url_head)) == 0 ) | 1334 if( strncmp(url_head, (char *)buf, strlen(url_head)) == 0 ) |
1335 xd->status_15 = P2P_HEAD_REQUESTED; | 1335 xd->status_15 = P2P_HEAD_REQUESTED; |
1336 else if( strncmp(url_get, (char *)buf, strlen(url_get)) == 0 ) | 1336 else if( strncmp(url_get, (char *)buf, strlen(url_get)) == 0 ) |
1337 xd->status_15 = P2P_GET_REQUESTED; | 1337 xd->status_15 = P2P_GET_REQUESTED; |
1338 else { | 1338 else { |
1403 PurpleAccount *account; | 1403 PurpleAccount *account; |
1404 struct yahoo_data *yd; | 1404 struct yahoo_data *yd; |
1405 gchar *filename; | 1405 gchar *filename; |
1406 const char *local_ip; | 1406 const char *local_ip; |
1407 gchar *url_to_send = NULL; | 1407 gchar *url_to_send = NULL; |
1408 char **split; | |
1409 char *filename_without_spaces = NULL; | |
1408 | 1410 |
1409 xfer = data; | 1411 xfer = data; |
1410 if ( !( (xd = xfer->data) || (listenfd != -1) ) ) { | 1412 if ( !( (xd = xfer->data) || (listenfd != -1) ) ) { |
1411 purple_debug_warning("yahoo","p2p: error starting server for p2p file transfer\n"); | 1413 purple_debug_warning("yahoo","p2p: error starting server for p2p file transfer\n"); |
1412 purple_xfer_cancel_remote(xfer); | 1414 purple_xfer_cancel_remote(xfer); |
1420 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_INFO_15, YAHOO_STATUS_AVAILABLE, yd->session_id); | 1422 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_INFO_15, YAHOO_STATUS_AVAILABLE, yd->session_id); |
1421 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer)); | 1423 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer)); |
1422 | 1424 |
1423 local_ip = purple_network_get_my_ip(listenfd); | 1425 local_ip = purple_network_get_my_ip(listenfd); |
1424 xd->yahoo_local_p2p_ft_server_port = purple_network_get_port_from_fd(listenfd); | 1426 xd->yahoo_local_p2p_ft_server_port = purple_network_get_port_from_fd(listenfd); |
1425 xd->xfer_url = g_strdup_printf("/Messenger.%s.%d000%s?AppID=Messenger&UserID=%s&K=lc9lu2u89gz1llmplwksajkjx", xfer->who, (int)time(NULL), filename, xfer->who); | 1427 |
1428 split = g_strsplit(filename, " ", 0); | |
1429 filename_without_spaces = g_strjoinv("+", split); | |
1430 xd->xfer_url = g_strdup_printf("/Messenger.%s.%d000%s?AppID=Messenger&UserID=%s&K=lc9lu2u89gz1llmplwksajkjx", xfer->who, (int)time(NULL), filename_without_spaces, xfer->who); | |
1426 url_to_send = g_strdup_printf("http://%s:%d%s", local_ip, xd->yahoo_local_p2p_ft_server_port, xd->xfer_url); | 1431 url_to_send = g_strdup_printf("http://%s:%d%s", local_ip, xd->yahoo_local_p2p_ft_server_port, xd->xfer_url); |
1427 xd->info_val_249 = 1; /* 249=1: we are p2p server */ | 1432 xd->info_val_249 = 1; /* 249=1: we are p2p server */ |
1428 | 1433 |
1429 yahoo_packet_hash(pkt, "ssssis", | 1434 yahoo_packet_hash(pkt, "ssssis", |
1430 1, purple_normalize(account, purple_account_get_username(account)), | 1435 1, purple_normalize(account, purple_account_get_username(account)), |
1435 250, url_to_send); | 1440 250, url_to_send); |
1436 yahoo_packet_send_and_free(pkt, yd); | 1441 yahoo_packet_send_and_free(pkt, yd); |
1437 | 1442 |
1438 g_free(filename); | 1443 g_free(filename); |
1439 g_free(url_to_send); | 1444 g_free(url_to_send); |
1445 g_strfreev(split); | |
1446 g_free(filename_without_spaces); | |
1440 } | 1447 } |
1441 | 1448 |
1442 /* Add an Input Read event to the file descriptor */ | 1449 /* Add an Input Read event to the file descriptor */ |
1443 xd->yahoo_local_p2p_ft_server_fd = listenfd; | 1450 xd->yahoo_local_p2p_ft_server_fd = listenfd; |
1444 xd->yahoo_p2p_ft_server_watcher = purple_input_add(listenfd, PURPLE_INPUT_READ, yahoo_p2p_ft_server_send_connected_cb, data); | 1451 xd->yahoo_p2p_ft_server_watcher = purple_input_add(listenfd, PURPLE_INPUT_READ, yahoo_p2p_ft_server_send_connected_cb, data); |