Changeset c735200
- Timestamp:
- 2010-03-22T01:20:40Z (15 years ago)
- Branches:
- master
- Children:
- edfc6db
- Parents:
- 437bd9b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/purple/purple.c
r437bd9b rc735200 665 665 }; 666 666 667 static void prplcb_xfer( PurpleXfer *xfer ) 668 { 669 fprintf( stderr, "ft bla: 0x%p\n", xfer ); 667 struct prpl_xfer_data 668 { 669 PurpleXfer *xfer; 670 file_transfer_t *ft; 671 gint ready_timer; 672 }; 673 674 /* Glorious hack: We seem to have to remind at least some libpurple plugins 675 that we're ready because this info may get lost if we give it too early. 676 So just do it ten times a second. :-/ */ 677 static gboolean prplcb_xfer_write_request_cb( gpointer data, gint fd, b_input_condition cond ) 678 { 679 purple_xfer_ui_ready( data ); 680 return TRUE; 681 } 682 683 static gboolean prpl_xfer_write_request( struct file_transfer *ft ) 684 { 685 struct prpl_xfer_data *px = ft->data; 686 px->ready_timer = b_timeout_add( 100, prplcb_xfer_write_request_cb, px->xfer ); 687 return TRUE; 688 } 689 690 static gssize prplcb_xfer_write( PurpleXfer *xfer, const guchar *buffer, gssize size ) 691 { 692 struct prpl_xfer_data *px = xfer->ui_data; 693 gboolean st; 694 695 b_event_remove( px->ready_timer ); 696 px->ready_timer = 0; 697 698 st = px->ft->write( px->ft, (char*) buffer, size ); 699 700 if( st && xfer->bytes_remaining == size ) 701 imcb_file_finished( px->ft ); 702 703 return st ? size : 0; 670 704 } 671 705 672 706 static void prpl_xfer_accept( struct file_transfer *ft ) 673 707 { 674 purple_xfer_request_accepted( ft->data, NULL ); 675 purple_xfer_ui_ready( ft->data ); 676 } 677 678 static void prpl_xfer_reject( struct file_transfer *ft ) 679 { 680 purple_xfer_request_denied( ft->data ); 708 struct prpl_xfer_data *px = ft->data; 709 purple_xfer_request_accepted( px->xfer, NULL ); 710 prpl_xfer_write_request( ft ); 711 } 712 713 static void prpl_xfer_canceled( struct file_transfer *ft, char *reason ) 714 { 715 struct prpl_xfer_data *px = ft->data; 716 purple_xfer_request_denied( px->xfer ); 681 717 } 682 718 … … 685 721 PurpleXfer *xfer = data; 686 722 struct im_connection *ic = purple_ic_by_pa( xfer->account ); 687 file_transfer_t *ft; 688 689 ft = imcb_file_send_start( ic, xfer->who, xfer->filename, xfer->size ); 690 ft->data = xfer; 691 xfer->ui_data = ft; 692 693 ft->accept = prpl_xfer_accept; 723 struct prpl_xfer_data *px = g_new0( struct prpl_xfer_data, 1 ); 724 PurpleBuddy *buddy; 725 const char *who; 726 727 buddy = purple_find_buddy( xfer->account, xfer->who ); 728 who = buddy ? purple_buddy_get_name( buddy ) : xfer->who; 729 730 /* TODO(wilmer): After spreading some more const goodness in BitlBee, 731 remove the evil cast below. */ 732 px->ft = imcb_file_send_start( ic, (char*) who, xfer->filename, xfer->size ); 733 px->ft->data = px; 734 px->xfer = data; 735 px->xfer->ui_data = px; 736 737 px->ft->accept = prpl_xfer_accept; 738 px->ft->canceled = prpl_xfer_canceled; 739 px->ft->write_request = prpl_xfer_write_request; 694 740 695 741 return FALSE; … … 698 744 static void prplcb_xfer_new( PurpleXfer *xfer ) 699 745 { 746 /* This should suppress the stupid file dialog. */ 700 747 purple_xfer_set_local_filename( xfer, "/tmp/wtf123" ); 701 748 702 fprintf( stderr, "ft_new bla: 0x%p\n", xfer );703 749 /* Sadly the xfer struct is still empty ATM so come back after 750 the caller is done. */ 704 751 b_timeout_add( 0, prplcb_xfer_new_cb, xfer ); 705 752 } … … 708 755 { 709 756 prplcb_xfer_new, 710 prplcb_xfer, 711 prplcb_xfer, 712 prplcb_xfer, 713 prplcb_xfer, 714 prplcb_xfer, 715 prplcb_xfer, 716 prplcb_xfer, 717 prplcb_xfer, 718 prplcb_xfer, 757 NULL, 758 NULL, 759 NULL, 760 NULL, 761 NULL, 762 prplcb_xfer_write, 719 763 }; 720 764 … … 727 771 purple_notify_set_ui_ops( &bee_notify_uiops ); 728 772 purple_xfers_set_ui_ops( &bee_xfer_uiops ); 729 purple_debug_set_ui_ops( &bee_debug_uiops );773 //purple_debug_set_ui_ops( &bee_debug_uiops ); 730 774 } 731 775
Note: See TracChangeset
for help on using the changeset viewer.