Changes in protocols/purple/ft.c [ea90275:98d46d5]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/purple/ft.c
rea90275 r98d46d5 42 42 char *fn, *handle; 43 43 gboolean ui_wants_data; 44 int timeout;45 44 }; 46 45 … … 65 64 struct prpl_xfer_data *px = ft->data; 66 65 67 if (px->xfer) { 68 if (!purple_xfer_is_completed(px->xfer) && !purple_xfer_is_canceled(px->xfer)) { 69 purple_xfer_cancel_local(px->xfer); 70 } 71 px->xfer->ui_data = NULL; 72 purple_xfer_unref(px->xfer); 73 px->xfer = NULL; 74 } 75 } 76 77 static void prpl_xfer_free(struct file_transfer *ft) 78 { 79 struct prpl_xfer_data *px = ft->data; 80 struct purple_data *pd = px->ic->proto_data; 81 82 pd->filetransfers = g_slist_remove(pd->filetransfers, px); 83 84 if (px->xfer) { 85 px->xfer->ui_data = NULL; 86 purple_xfer_unref(px->xfer); 87 } 88 89 if (px->timeout) { 90 b_event_remove(px->timeout); 91 } 92 93 g_free(px->fn); 94 g_free(px->handle); 95 if (px->fd >= 0) { 96 close(px->fd); 97 } 98 g_free(px); 66 purple_xfer_request_denied(px->xfer); 99 67 } 100 68 101 69 static void prplcb_xfer_new(PurpleXfer *xfer) 102 70 { 103 purple_xfer_ref(xfer);104 105 71 if (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) { 106 72 struct prpl_xfer_data *px = g_new0(struct prpl_xfer_data, 1); 107 struct purple_data *pd;108 73 109 74 xfer->ui_data = px; … … 113 78 px->ic = purple_ic_by_pa(xfer->account); 114 79 115 pd = px->ic->proto_data;116 pd->filetransfers = g_slist_prepend(pd->filetransfers, px);117 118 80 purple_xfer_set_local_filename(xfer, px->fn); 119 81 … … 150 112 px->ft->accept = prpl_xfer_accept; 151 113 px->ft->canceled = prpl_xfer_canceled; 152 px->ft->free = prpl_xfer_free;153 114 px->ft->write_request = prpl_xfer_write_request; 154 115 … … 203 164 204 165 166 /* Generic (IM<>UI): */ 205 167 static void prplcb_xfer_destroy(PurpleXfer *xfer) 206 168 { 207 169 struct prpl_xfer_data *px = xfer->ui_data; 208 170 209 if (px) { 210 px->xfer = NULL; 211 } 171 g_free(px->fn); 172 g_free(px->handle); 173 if (px->fd >= 0) { 174 close(px->fd); 175 } 176 g_free(px); 212 177 } 213 178 … … 259 224 struct prpl_xfer_data *px = xfer->ui_data; 260 225 261 if (px && px->ft) {226 if (px->ft) { 262 227 imcb_file_canceled(px->ic, px->ft, "Canceled by remote end"); 263 } else if (px){228 } else { 264 229 /* px->ft == NULL for sends, because of the two stages. :-/ */ 265 230 imcb_error(px->ic, "File transfer cancelled by remote end"); … … 275 240 { 276 241 struct prpl_xfer_data *px = g_new0(struct prpl_xfer_data, 1); 277 struct purple_data *pd;278 242 char *dir, *basename; 279 243 280 244 ft->data = px; 281 245 px->ft = ft; 282 px->ft->free = prpl_xfer_free;283 246 284 247 dir = g_strdup("/tmp/bitlbee-purple-ft.XXXXXX"); … … 309 272 px->handle = g_strdup(handle); 310 273 311 pd = px->ic->proto_data;312 pd->filetransfers = g_slist_prepend(pd->filetransfers, px);313 314 274 imcb_log(ic, 315 275 "Due to libpurple limitations, the file has to be cached locally before proceeding with the actual file transfer. Please wait..."); 316 276 317 px->timeout =b_timeout_add(0, purple_transfer_request_cb, ft);277 b_timeout_add(0, purple_transfer_request_cb, ft); 318 278 } 319 279 … … 335 295 struct prpl_xfer_data *px = ft->data; 336 296 337 px->timeout = 0;338 339 297 if (ft->write == NULL) { 340 298 ft->write = prpl_xfer_write; … … 364 322 px->ft = NULL; 365 323 } else { 366 px->timeout =b_timeout_add(0, purple_transfer_request_cb, ft);324 b_timeout_add(0, purple_transfer_request_cb, ft); 367 325 } 368 326 369 327 return TRUE; 370 }371 372 void purple_transfer_cancel_all(struct im_connection *ic)373 {374 struct purple_data *pd = ic->proto_data;375 376 while (pd->filetransfers) {377 struct prpl_xfer_data *px = pd->filetransfers->data;378 379 if (px->ft) {380 imcb_file_canceled(ic, px->ft, "Logging out");381 }382 383 pd->filetransfers = g_slist_remove(pd->filetransfers, px);384 }385 328 } 386 329
Note: See TracChangeset
for help on using the changeset viewer.