Changeset 553767c
- Timestamp:
- 2010-05-17T20:30:45Z (14 years ago)
- Branches:
- master
- Children:
- 8822d23
- Parents:
- 2309152
- Location:
- protocols/purple
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/purple/ft.c
r2309152 r553767c 22 22 \***************************************************************************/ 23 23 24 /* Do file transfers via disk for now, since libpurple was really designed 25 for straight-to/from disk fts and is only just learning how to pass the 26 file contents the the UI instead (2.6.0 and higher it seems, and with 27 varying levels of success). */ 28 24 29 #include "bitlbee.h" 25 30 … … 42 47 struct im_connection *purple_ic_by_pa( PurpleAccount *pa ); 43 48 44 /* Glorious hack: We seem to have to remind at least some libpurple plugins45 that we're ready because this info may get lost if we give it too early.46 So just do it ten times a second. :-/ */47 static gboolean prplcb_xfer_write_request_cb( gpointer data, gint fd, b_input_condition cond )48 {49 struct prpl_xfer_data *px = data;50 51 purple_xfer_ui_ready( px->xfer );52 53 return purple_xfer_get_type( px->xfer ) == PURPLE_XFER_RECEIVE;54 }55 56 49 static gboolean prpl_xfer_write_request( struct file_transfer *ft ) 57 50 { 58 struct prpl_xfer_data *px = ft->data; 59 px->ready_timer = b_timeout_add( 100, prplcb_xfer_write_request_cb, px ); 60 return TRUE; 51 return FALSE; 61 52 } 62 53 … … 65 56 struct prpl_xfer_data *px = ft->data; 66 57 67 px->buf = g_memdup( buffer, len ); 68 px->buf_len = len; 69 70 //purple_xfer_ui_ready( px->xfer ); 71 px->ready_timer = b_timeout_add( 0, prplcb_xfer_write_request_cb, px ); 72 73 return TRUE; 58 return FALSE; 74 59 } 75 60 … … 85 70 struct prpl_xfer_data *px = ft->data; 86 71 purple_xfer_request_denied( px->xfer ); 72 } 73 74 static gboolean prplcb_xfer_new_send_cb( gpointer data, gint fd, b_input_condition cond ); 75 76 static void prplcb_xfer_new( PurpleXfer *xfer ) 77 { 78 if( purple_xfer_get_type( xfer ) == PURPLE_XFER_RECEIVE ) 79 { 80 /* This should suppress the stupid file dialog. */ 81 purple_xfer_set_local_filename( xfer, "/tmp/wtf123" ); 82 83 /* Sadly the xfer struct is still empty ATM so come back after 84 the caller is done. */ 85 b_timeout_add( 0, prplcb_xfer_new_send_cb, xfer ); 86 } 87 else 88 { 89 /* 90 struct prpl_xfer_data *px = g_new0( struct prpl_xfer_data, 1 ); 91 92 px->ft = next_ft; 93 px->ft->data = px; 94 px->xfer = xfer; 95 px->xfer->ui_data = px; 96 97 purple_xfer_set_filename( xfer, px->ft->file_name ); 98 purple_xfer_set_size( xfer, px->ft->file_size ); 99 100 next_ft = NULL; 101 */ 102 } 87 103 } 88 104 … … 112 128 } 113 129 114 static void prplcb_xfer_new( PurpleXfer *xfer )115 {116 if( purple_xfer_get_type( xfer ) == PURPLE_XFER_RECEIVE )117 {118 /* This should suppress the stupid file dialog. */119 purple_xfer_set_local_filename( xfer, "/tmp/wtf123" );120 121 /* Sadly the xfer struct is still empty ATM so come back after122 the caller is done. */123 b_timeout_add( 0, prplcb_xfer_new_send_cb, xfer );124 }125 else126 {127 struct prpl_xfer_data *px = g_new0( struct prpl_xfer_data, 1 );128 129 px->ft = next_ft;130 px->ft->data = px;131 px->xfer = xfer;132 px->xfer->ui_data = px;133 134 purple_xfer_set_filename( xfer, px->ft->file_name );135 purple_xfer_set_size( xfer, px->ft->file_size );136 137 next_ft = NULL;138 }139 }140 141 130 static void prplcb_xfer_progress( PurpleXfer *xfer, double percent ) 142 131 { … … 149 138 } 150 139 151 static gssize prplcb_xfer_write( PurpleXfer *xfer, const guchar *buffer, gssize size )152 {153 struct prpl_xfer_data *px = xfer->ui_data;154 gboolean st;155 156 fprintf( stderr, "xfer_write %d %d\n", size, px->buf_len );157 158 b_event_remove( px->ready_timer );159 px->ready_timer = 0;160 161 st = px->ft->write( px->ft, (char*) buffer, size );162 163 if( st && xfer->bytes_remaining == size )164 imcb_file_finished( px->ft );165 166 return st ? size : 0;167 }168 169 gssize prplcb_xfer_read( PurpleXfer *xfer, guchar **buffer, gssize size )170 {171 struct prpl_xfer_data *px = xfer->ui_data;172 173 fprintf( stderr, "xfer_read %d %d\n", size, px->buf_len );174 175 if( px->buf )176 {177 *buffer = px->buf;178 px->buf = NULL;179 180 px->ft->write_request( px->ft );181 182 return px->buf_len;183 }184 185 return 0;186 }187 188 140 PurpleXferUiOps bee_xfer_uiops = 189 141 { … … 194 146 prplcb_xfer_dbg, 195 147 prplcb_xfer_dbg, 196 prplcb_xfer_write,197 prplcb_xfer_read,148 NULL, 149 NULL, 198 150 prplcb_xfer_dbg, 199 151 }; … … 215 167 px = ft->data; 216 168 imcb_file_recv_start( ft ); 217 218 px->ready_timer = b_timeout_add( 100, prplcb_xfer_send_cb, px );219 169 } 220 221 static gboolean prplcb_xfer_send_cb( gpointer data, gint fd, b_input_condition cond )222 {223 struct prpl_xfer_data *px = data;224 225 if( px->ft->status & FT_STATUS_TRANSFERRING )226 {227 fprintf( stderr, "The ft, it is ready...\n" );228 px->ft->write_request( px->ft );229 230 return FALSE;231 }232 233 return TRUE;234 }
Note: See TracChangeset
for help on using the changeset viewer.