Changeset edfc6db for protocols/purple
- Timestamp:
- 2010-03-23T01:06:25Z (15 years ago)
- Branches:
- master
- Children:
- a897467
- Parents:
- c735200
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/purple/purple.c
rc735200 redfc6db 365 365 } 366 366 367 void purple_transfer_request( struct im_connection *ic, file_transfer_t *ft, char *handle ); 368 367 369 static void purple_ui_init(); 368 370 … … 665 667 }; 666 668 669 667 670 struct prpl_xfer_data 668 671 { … … 670 673 file_transfer_t *ft; 671 674 gint ready_timer; 672 }; 675 char *buf; 676 int buf_len; 677 }; 678 679 static file_transfer_t *next_ft; 673 680 674 681 /* Glorious hack: We seem to have to remind at least some libpurple plugins … … 677 684 static gboolean prplcb_xfer_write_request_cb( gpointer data, gint fd, b_input_condition cond ) 678 685 { 679 purple_xfer_ui_ready( data ); 680 return TRUE; 686 struct prpl_xfer_data *px = data; 687 688 purple_xfer_ui_ready( px->xfer ); 689 690 return purple_xfer_get_type( px->xfer ) == PURPLE_XFER_RECEIVE; 681 691 } 682 692 … … 684 694 { 685 695 struct prpl_xfer_data *px = ft->data; 686 px->ready_timer = b_timeout_add( 100, prplcb_xfer_write_request_cb, px ->xfer);696 px->ready_timer = b_timeout_add( 100, prplcb_xfer_write_request_cb, px ); 687 697 return TRUE; 688 698 } … … 702 712 703 713 return st ? size : 0; 714 } 715 716 static gboolean prpl_xfer_write( struct file_transfer *ft, char *buffer, unsigned int len ) 717 { 718 struct prpl_xfer_data *px = ft->data; 719 720 px->buf = g_memdup( buffer, len ); 721 px->buf_len = len; 722 723 //purple_xfer_ui_ready( px->xfer ); 724 px->ready_timer = b_timeout_add( 0, prplcb_xfer_write_request_cb, px ); 725 726 return TRUE; 704 727 } 705 728 … … 717 740 } 718 741 719 static gboolean prplcb_xfer_new_ cb( gpointer data, gint fd, b_input_condition cond )742 static gboolean prplcb_xfer_new_send_cb( gpointer data, gint fd, b_input_condition cond ) 720 743 { 721 744 PurpleXfer *xfer = data; … … 744 767 static void prplcb_xfer_new( PurpleXfer *xfer ) 745 768 { 746 /* This should suppress the stupid file dialog. */ 747 purple_xfer_set_local_filename( xfer, "/tmp/wtf123" ); 748 749 /* Sadly the xfer struct is still empty ATM so come back after 750 the caller is done. */ 751 b_timeout_add( 0, prplcb_xfer_new_cb, xfer ); 769 if( purple_xfer_get_type( xfer ) == PURPLE_XFER_RECEIVE ) 770 { 771 /* This should suppress the stupid file dialog. */ 772 purple_xfer_set_local_filename( xfer, "/tmp/wtf123" ); 773 774 /* Sadly the xfer struct is still empty ATM so come back after 775 the caller is done. */ 776 b_timeout_add( 0, prplcb_xfer_new_send_cb, xfer ); 777 } 778 else 779 { 780 struct prpl_xfer_data *px = g_new0( struct prpl_xfer_data, 1 ); 781 782 px->ft = next_ft; 783 px->ft->data = px; 784 px->xfer = xfer; 785 px->xfer->ui_data = px; 786 787 purple_xfer_set_filename( xfer, px->ft->file_name ); 788 purple_xfer_set_size( xfer, px->ft->file_size ); 789 790 next_ft = NULL; 791 } 792 } 793 794 static void prplcb_xfer_dbg( PurpleXfer *xfer ) 795 { 796 fprintf( stderr, "prplcb_xfer_dbg 0x%p\n", xfer ); 797 } 798 799 gssize prplcb_xfer_read( PurpleXfer *xfer, guchar **buffer, gssize size ) 800 { 801 struct prpl_xfer_data *px = xfer->ui_data; 802 803 fprintf( stderr, "xfer_read %d %d\n", size, px->buf_len ); 804 805 if( px->buf ) 806 { 807 *buffer = px->buf; 808 px->buf = NULL; 809 810 px->ft->write_request( px->ft ); 811 812 return px->buf_len; 813 } 814 815 return 0; 752 816 } 753 817 … … 755 819 { 756 820 prplcb_xfer_new, 757 NULL,758 NULL,759 NULL,760 NULL,761 NULL,821 prplcb_xfer_dbg, 822 prplcb_xfer_dbg, 823 prplcb_xfer_dbg, 824 prplcb_xfer_dbg, 825 prplcb_xfer_dbg, 762 826 prplcb_xfer_write, 763 }; 827 prplcb_xfer_read, 828 prplcb_xfer_dbg, 829 }; 830 831 static gboolean prplcb_xfer_send_cb( gpointer data, gint fd, b_input_condition cond ); 832 833 void purple_transfer_request( struct im_connection *ic, file_transfer_t *ft, char *handle ) 834 { 835 PurpleAccount *pa = ic->proto_data; 836 struct prpl_xfer_data *px; 837 838 /* xfer_new() will pick up this variable. It's a hack but we're not 839 multi-threaded anyway. */ 840 next_ft = ft; 841 serv_send_file( purple_account_get_connection( pa ), handle, ft->file_name ); 842 843 ft->write = prpl_xfer_write; 844 845 px = ft->data; 846 imcb_file_recv_start( ft ); 847 848 px->ready_timer = b_timeout_add( 100, prplcb_xfer_send_cb, px ); 849 } 850 851 static gboolean prplcb_xfer_send_cb( gpointer data, gint fd, b_input_condition cond ) 852 { 853 struct prpl_xfer_data *px = data; 854 855 if( px->ft->status & FT_STATUS_TRANSFERRING ) 856 { 857 fprintf( stderr, "The ft, it is ready...\n" ); 858 px->ft->write_request( px->ft ); 859 860 return FALSE; 861 } 862 863 return TRUE; 864 } 764 865 765 866 static void purple_ui_init() … … 771 872 purple_notify_set_ui_ops( &bee_notify_uiops ); 772 873 purple_xfers_set_ui_ops( &bee_xfer_uiops ); 773 //purple_debug_set_ui_ops( &bee_debug_uiops );874 purple_debug_set_ui_ops( &bee_debug_uiops ); 774 875 } 775 876 … … 817 918 funcs.send_typing = purple_send_typing; 818 919 funcs.handle_cmp = g_strcasecmp; 920 /* TODO(wilmer): Set this one only for protocols that support it? */ 921 funcs.transfer_request = purple_transfer_request; 819 922 820 923 help = g_string_new("BitlBee libpurple module supports the following IM protocols:\n");
Note: See TracChangeset
for help on using the changeset viewer.