From 7d52f273c329efc1c84d5af056185fd2dbed7ef9 Mon Sep 17 00:00:00 2001 From: Jakub Adam Date: Tue, 29 Jul 2014 15:36:53 +0200 Subject: [PATCH] filetransfer: use 'request_denied' callback in sipe_file_transfer Replaces sipe_core_ft_cancel(). It also doesn't make sense to use it in outbound file transfer. --- src/api/sipe-core.h | 2 +- src/core/sipe-ft.c | 4 +++- src/miranda/miranda-ft.c | 4 ++-- src/purple/purple-ft.c | 7 +++++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/api/sipe-core.h b/src/api/sipe-core.h index 2403a4a0..7338e3f7 100644 --- a/src/api/sipe-core.h +++ b/src/api/sipe-core.h @@ -80,6 +80,7 @@ struct sipe_file_transfer { void (* init)(struct sipe_file_transfer *ft, const gchar *filename, gsize size, const gchar *who); + void (* request_denied)(struct sipe_file_transfer *ft); }; /** @@ -448,7 +449,6 @@ void sipe_core_media_test_call(struct sipe_core_public *sipe_public); /* file transfer */ struct sipe_file_transfer *sipe_core_ft_allocate(struct sipe_core_public *sipe_public); void sipe_core_ft_deallocate(struct sipe_file_transfer *ft); -void sipe_core_ft_cancel(struct sipe_file_transfer *ft); void sipe_core_tftp_incoming_start(struct sipe_file_transfer *ft, gsize total_size); diff --git a/src/core/sipe-ft.c b/src/core/sipe-ft.c index 284af92c..0cbc76a4 100644 --- a/src/core/sipe-ft.c +++ b/src/core/sipe-ft.c @@ -137,7 +137,8 @@ static void sipe_ft_request(struct sipe_file_transfer_private *ft_private, NULL); } -void sipe_core_ft_cancel(struct sipe_file_transfer *ft) +static void +ft_request_denied(struct sipe_file_transfer *ft) { struct sipe_file_transfer_private *ft_private = SIPE_FILE_TRANSFER_PRIVATE; @@ -309,6 +310,7 @@ void sipe_ft_incoming_transfer(struct sipe_core_private *sipe_private, ft_private->sipe_private = sipe_private; ft_private->public.init = ft_incoming_init; + ft_private->public.request_denied = ft_request_denied; generate_key(ft_private->encryption_key, SIPE_FT_KEY_LENGTH); generate_key(ft_private->hash_key, SIPE_FT_KEY_LENGTH); diff --git a/src/miranda/miranda-ft.c b/src/miranda/miranda-ft.c index 2a6e9e1c..7dfe4212 100644 --- a/src/miranda/miranda-ft.c +++ b/src/miranda/miranda-ft.c @@ -733,8 +733,8 @@ sipe_miranda_FileDeny( SIPPROTO *pr, HANDLE hContact, HANDLE hTransfer, const PR { struct sipe_file_transfer *ft = (struct sipe_file_transfer *)hTransfer; FT_SIPE_DEBUG_INFO("FileDeny: reason <%s>", szReason); - if (ft->backend_private->incoming) - sipe_core_ft_cancel(ft); + if (ft->backend_private->incoming && ft->request_denied) + ft->request_denied(ft); free_xfer_struct(ft->backend_private); return 0; } diff --git a/src/purple/purple-ft.c b/src/purple/purple-ft.c index 3b619abe..69e055e1 100644 --- a/src/purple/purple-ft.c +++ b/src/purple/purple-ft.c @@ -162,8 +162,11 @@ ft_free_xfer_struct(PurpleXfer *xfer) static void ft_request_denied(PurpleXfer *xfer) { - if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_RECEIVE) - sipe_core_ft_cancel(PURPLE_XFER_TO_SIPE_FILE_TRANSFER); + struct sipe_file_transfer *ft = PURPLE_XFER_TO_SIPE_FILE_TRANSFER; + if (ft->request_denied) { + ft->request_denied(ft); + } + ft_free_xfer_struct(xfer); } -- 2.11.4.GIT