| 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; |
| 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); |
| 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; |