Changeset ea90275
- Timestamp:
- 2016-11-13T20:10:17Z (8 years ago)
- Branches:
- master
- Children:
- 9f03c47
- Parents:
- 701ab812
- git-author:
- dequis <dx@…> (13-11-16 20:00:04)
- git-committer:
- dequis <dx@…> (13-11-16 20:10:17)
- Location:
- protocols/purple
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/purple/bpurple.h
r701ab812 rea90275 14 14 guint next_request_id; 15 15 char *chat_list_server; 16 GSList *filetransfers; 16 17 }; 17 18 -
protocols/purple/ft.c
r701ab812 rea90275 42 42 char *fn, *handle; 43 43 gboolean ui_wants_data; 44 int timeout; 44 45 }; 45 46 … … 64 65 struct prpl_xfer_data *px = ft->data; 65 66 66 purple_xfer_request_denied(px->xfer); 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); 67 99 } 68 100 69 101 static void prplcb_xfer_new(PurpleXfer *xfer) 70 102 { 103 purple_xfer_ref(xfer); 104 71 105 if (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) { 72 106 struct prpl_xfer_data *px = g_new0(struct prpl_xfer_data, 1); 107 struct purple_data *pd; 73 108 74 109 xfer->ui_data = px; … … 77 112 px->fd = -1; 78 113 px->ic = purple_ic_by_pa(xfer->account); 114 115 pd = px->ic->proto_data; 116 pd->filetransfers = g_slist_prepend(pd->filetransfers, px); 79 117 80 118 purple_xfer_set_local_filename(xfer, px->fn); … … 112 150 px->ft->accept = prpl_xfer_accept; 113 151 px->ft->canceled = prpl_xfer_canceled; 152 px->ft->free = prpl_xfer_free; 114 153 px->ft->write_request = prpl_xfer_write_request; 115 154 … … 164 203 165 204 166 /* Generic (IM<>UI): */167 205 static void prplcb_xfer_destroy(PurpleXfer *xfer) 168 206 { 169 207 struct prpl_xfer_data *px = xfer->ui_data; 170 208 171 g_free(px->fn); 172 g_free(px->handle); 173 if (px->fd >= 0) { 174 close(px->fd); 175 } 176 g_free(px); 209 if (px) { 210 px->xfer = NULL; 211 } 177 212 } 178 213 … … 224 259 struct prpl_xfer_data *px = xfer->ui_data; 225 260 226 if (px ->ft) {261 if (px && px->ft) { 227 262 imcb_file_canceled(px->ic, px->ft, "Canceled by remote end"); 228 } else {263 } else if (px) { 229 264 /* px->ft == NULL for sends, because of the two stages. :-/ */ 230 265 imcb_error(px->ic, "File transfer cancelled by remote end"); … … 240 275 { 241 276 struct prpl_xfer_data *px = g_new0(struct prpl_xfer_data, 1); 277 struct purple_data *pd; 242 278 char *dir, *basename; 243 279 244 280 ft->data = px; 245 281 px->ft = ft; 282 px->ft->free = prpl_xfer_free; 246 283 247 284 dir = g_strdup("/tmp/bitlbee-purple-ft.XXXXXX"); … … 272 309 px->handle = g_strdup(handle); 273 310 311 pd = px->ic->proto_data; 312 pd->filetransfers = g_slist_prepend(pd->filetransfers, px); 313 274 314 imcb_log(ic, 275 315 "Due to libpurple limitations, the file has to be cached locally before proceeding with the actual file transfer. Please wait..."); 276 316 277 b_timeout_add(0, purple_transfer_request_cb, ft);317 px->timeout = b_timeout_add(0, purple_transfer_request_cb, ft); 278 318 } 279 319 … … 295 335 struct prpl_xfer_data *px = ft->data; 296 336 337 px->timeout = 0; 338 297 339 if (ft->write == NULL) { 298 340 ft->write = prpl_xfer_write; … … 322 364 px->ft = NULL; 323 365 } else { 324 b_timeout_add(0, purple_transfer_request_cb, ft);366 px->timeout = b_timeout_add(0, purple_transfer_request_cb, ft); 325 367 } 326 368 327 369 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 } 328 385 } 329 386 -
protocols/purple/purple.c
r701ab812 rea90275 43 43 const char *message, const char *who); 44 44 45 void purple_transfer_cancel_all(struct im_connection *ic); 46 45 47 /* purple_request_input specific stuff */ 46 48 typedef void (*ri_callback_t)(gpointer, const gchar *); … … 383 385 while (ic->groupchats) { 384 386 imcb_chat_free(ic->groupchats->data); 387 } 388 389 if (pd->filetransfers) { 390 purple_transfer_cancel_all(ic); 385 391 } 386 392
Note: See TracChangeset
for help on using the changeset viewer.