libpurple/protocols/qq/send_file.c

branch
openq
changeset 31393
04447b1f6403
parent 30706
612b36b49058
equal deleted inserted replaced
31392:93902a4213b6 31393:04447b1f6403
276 } 276 }
277 277
278 278
279 /* fill in the common information of file transfer */ 279 /* fill in the common information of file transfer */
280 static gint _qq_create_packet_file_header 280 static gint _qq_create_packet_file_header
281 (guint8 *raw_data, guint32 to_uid, guint16 message_type, qq_data *qd, gboolean seq_ack) 281 (guint8 *raw_data, UID to_uid, guint16 message_type, qq_data *qd, gboolean seq_ack)
282 { 282 {
283 gint bytes; 283 gint bytes;
284 time_t now; 284 time_t now;
285 guint16 seq; 285 guint16 seq;
286 ft_info *info; 286 ft_info *info;
428 } 428 }
429 /* xfer->watcher = purple_input_add(info->recv_fd, PURPLE_INPUT_READ, _qq_xfer_recv_packet, xfer); */ 429 /* xfer->watcher = purple_input_add(info->recv_fd, PURPLE_INPUT_READ, _qq_xfer_recv_packet, xfer); */
430 } 430 }
431 431
432 /* create the QQ_FILE_TRANS_REQ packet with file infomations */ 432 /* create the QQ_FILE_TRANS_REQ packet with file infomations */
433 static void _qq_send_packet_file_request (PurpleConnection *gc, guint32 to_uid, gchar *filename, gint filesize) 433 static void _qq_send_packet_file_request (PurpleConnection *gc, UID to_uid, gchar *filename, gint filesize)
434 { 434 {
435 qq_data *qd; 435 qq_data *qd;
436 guint8 *raw_data; 436 guint8 *raw_data;
437 gchar *filelen_str; 437 gchar *filelen_str;
438 gint filename_len, filelen_strlen, packet_len, bytes; 438 gint filename_len, filelen_strlen, packet_len, bytes;
480 480
481 g_free (filelen_str); 481 g_free (filelen_str);
482 } 482 }
483 483
484 /* tell the buddy we want to accept the file */ 484 /* tell the buddy we want to accept the file */
485 static void _qq_send_packet_file_accept(PurpleConnection *gc, guint32 to_uid) 485 static void _qq_send_packet_file_accept(PurpleConnection *gc, UID to_uid)
486 { 486 {
487 qq_data *qd; 487 qq_data *qd;
488 guint8 *raw_data; 488 guint8 *raw_data;
489 guint16 minor_port; 489 guint16 minor_port;
490 guint32 real_ip; 490 guint32 real_ip;
518 purple_debug_info("qq_send_packet_file_accept", 518 purple_debug_info("qq_send_packet_file_accept",
519 "%d bytes expected but got %d bytes\n", 519 "%d bytes expected but got %d bytes\n",
520 packet_len, bytes); 520 packet_len, bytes);
521 } 521 }
522 522
523 static void _qq_send_packet_file_notifyip(PurpleConnection *gc, guint32 to_uid) 523 static void _qq_send_packet_file_notifyip(PurpleConnection *gc, UID to_uid)
524 { 524 {
525 PurpleXfer *xfer; 525 PurpleXfer *xfer;
526 ft_info *info; 526 ft_info *info;
527 qq_data *qd; 527 qq_data *qd;
528 guint8 *raw_data; 528 guint8 *raw_data;
550 xfer->watcher = purple_input_add(info->recv_fd, PURPLE_INPUT_READ, _qq_xfer_recv_packet, xfer); 550 xfer->watcher = purple_input_add(info->recv_fd, PURPLE_INPUT_READ, _qq_xfer_recv_packet, xfer);
551 purple_input_add(info->major_fd, PURPLE_INPUT_READ, _qq_xfer_recv_packet, xfer); 551 purple_input_add(info->major_fd, PURPLE_INPUT_READ, _qq_xfer_recv_packet, xfer);
552 } 552 }
553 553
554 /* tell the buddy we don't want the file */ 554 /* tell the buddy we don't want the file */
555 static void _qq_send_packet_file_reject (PurpleConnection *gc, guint32 to_uid) 555 static void _qq_send_packet_file_reject (PurpleConnection *gc, UID to_uid)
556 { 556 {
557 qq_data *qd; 557 qq_data *qd;
558 guint8 *raw_data; 558 guint8 *raw_data;
559 gint packet_len, bytes; 559 gint packet_len, bytes;
560 560
574 "%d bytes expected but got %d bytes\n", 574 "%d bytes expected but got %d bytes\n",
575 packet_len, bytes); 575 packet_len, bytes);
576 } 576 }
577 577
578 /* tell the buddy to cancel transfer */ 578 /* tell the buddy to cancel transfer */
579 static void _qq_send_packet_file_cancel (PurpleConnection *gc, guint32 to_uid) 579 static void _qq_send_packet_file_cancel (PurpleConnection *gc, UID to_uid)
580 { 580 {
581 qq_data *qd; 581 qq_data *qd;
582 guint8 *raw_data; 582 guint8 *raw_data;
583 gint packet_len, bytes; 583 gint packet_len, bytes;
584 584
609 static void 609 static void
610 _qq_xfer_init (PurpleXfer * xfer) 610 _qq_xfer_init (PurpleXfer * xfer)
611 { 611 {
612 PurpleConnection *gc; 612 PurpleConnection *gc;
613 PurpleAccount *account; 613 PurpleAccount *account;
614 guint32 to_uid; 614 UID to_uid;
615 const gchar *filename; 615 const gchar *filename;
616 gchar *base_filename; 616 gchar *base_filename;
617 617
618 g_return_if_fail (xfer != NULL); 618 g_return_if_fail (xfer != NULL);
619 account = purple_xfer_get_account(xfer); 619 account = purple_xfer_get_account(xfer);
676 _qq_send_packet_file_accept(gc, purple_name_to_uid(xfer->who)); 676 _qq_send_packet_file_accept(gc, purple_name_to_uid(xfer->who));
677 } 677 }
678 678
679 /* process reject im for file transfer request */ 679 /* process reject im for file transfer request */
680 void qq_process_recv_file_reject (guint8 *data, gint data_len, 680 void qq_process_recv_file_reject (guint8 *data, gint data_len,
681 guint32 sender_uid, PurpleConnection *gc) 681 UID sender_uid, PurpleConnection *gc)
682 { 682 {
683 gchar *msg, *filename; 683 gchar *msg, *filename;
684 qq_data *qd; 684 qq_data *qd;
685 685
686 g_return_if_fail (data != NULL && data_len != 0); 686 g_return_if_fail (data != NULL && data_len != 0);
706 g_free(msg); 706 g_free(msg);
707 } 707 }
708 708
709 /* process cancel im for file transfer request */ 709 /* process cancel im for file transfer request */
710 void qq_process_recv_file_cancel (guint8 *data, gint data_len, 710 void qq_process_recv_file_cancel (guint8 *data, gint data_len,
711 guint32 sender_uid, PurpleConnection *gc) 711 UID sender_uid, PurpleConnection *gc)
712 { 712 {
713 gchar *msg, *filename; 713 gchar *msg, *filename;
714 qq_data *qd; 714 qq_data *qd;
715 715
716 g_return_if_fail (data != NULL && data_len != 0); 716 g_return_if_fail (data != NULL && data_len != 0);
736 g_free(filename); 736 g_free(filename);
737 g_free(msg); 737 g_free(msg);
738 } 738 }
739 739
740 /* process accept im for file transfer request */ 740 /* process accept im for file transfer request */
741 void qq_process_recv_file_accept(guint8 *data, gint data_len, guint32 sender_uid, PurpleConnection *gc) 741 void qq_process_recv_file_accept(guint8 *data, gint data_len, UID sender_uid, PurpleConnection *gc)
742 { 742 {
743 qq_data *qd; 743 qq_data *qd;
744 gint bytes; 744 gint bytes;
745 ft_info *info; 745 ft_info *info;
746 PurpleXfer *xfer; 746 PurpleXfer *xfer;
762 _qq_xfer_init_udp_channel(info); 762 _qq_xfer_init_udp_channel(info);
763 _qq_send_packet_file_notifyip(gc, sender_uid); 763 _qq_send_packet_file_notifyip(gc, sender_uid);
764 } 764 }
765 765
766 /* process request from buddy's im for file transfer request */ 766 /* process request from buddy's im for file transfer request */
767 void qq_process_recv_file_request(guint8 *data, gint data_len, guint32 sender_uid, PurpleConnection * gc) 767 void qq_process_recv_file_request(guint8 *data, gint data_len, UID sender_uid, PurpleConnection * gc)
768 { 768 {
769 qq_data *qd; 769 qq_data *qd;
770 PurpleXfer *xfer; 770 PurpleXfer *xfer;
771 gchar *sender_name, **fileinfo; 771 gchar *sender_name, **fileinfo;
772 ft_info *info; 772 ft_info *info;
872 info->use_major = FALSE; 872 info->use_major = FALSE;
873 */ 873 */
874 } 874 }
875 875
876 void qq_process_recv_file_notify(guint8 *data, gint data_len, 876 void qq_process_recv_file_notify(guint8 *data, gint data_len,
877 guint32 sender_uid, PurpleConnection *gc) 877 UID sender_uid, PurpleConnection *gc)
878 { 878 {
879 gint bytes; 879 gint bytes;
880 qq_data *qd; 880 qq_data *qd;
881 ft_info *info; 881 ft_info *info;
882 PurpleXfer *xfer; 882 PurpleXfer *xfer;

mercurial