From 03520fcd5285634163abf3ccb985a376fb9c795d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 24 Apr 2018 18:11:20 +0200 Subject: [PATCH] Fixed group chat's Send File + Text message test --- coreapi/lime.c | 2 +- include/linphone/api/c-content.h | 7 +++++++ src/c-wrapper/api/c-content.cpp | 10 ++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/coreapi/lime.c b/coreapi/lime.c index d0c07cd89..788a6c893 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -925,7 +925,7 @@ int lime_im_encryption_engine_process_uploading_file_cb(LinphoneImEncryptionEngi if (!buffer || *size == 0) return lime_encryptFile(linphone_content_get_cryptoContext_address(content), NULL, 0, NULL, NULL); - size_t file_size = linphone_content_get_size(content); + size_t file_size = linphone_content_get_file_size(content); if (file_size == 0) { ms_warning("File size has not been set, encryption will fail if not done in one step (if file is larger than 16K)"); } else if (offset + *size < file_size) { diff --git a/include/linphone/api/c-content.h b/include/linphone/api/c-content.h index 214755d5b..d7fbdc577 100644 --- a/include/linphone/api/c-content.h +++ b/include/linphone/api/c-content.h @@ -136,6 +136,13 @@ LINPHONE_PUBLIC void linphone_content_set_string_buffer (LinphoneContent *conten */ LINPHONE_PUBLIC size_t linphone_content_get_size (const LinphoneContent *content); +/** + * Get the file size if content is either a FileContent or a FileTransferContent. + * @param[in] content #LinphoneContent object. + * @return The represented file size. + */ +LINPHONE_PUBLIC size_t linphone_content_get_file_size(const LinphoneContent *content); + /** * Set the content data size, excluding null character despite null character is always set for convenience. * @param[in] content #LinphoneContent object diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index f3bc9870b..c0d939126 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -125,17 +125,19 @@ void linphone_content_set_string_buffer (LinphoneContent *content, const char *b L_GET_CPP_PTR_FROM_C_OBJECT(content)->setBodyFromUtf8(L_C_TO_STRING(buffer)); } -size_t linphone_content_get_size (const LinphoneContent *content) { +size_t linphone_content_get_file_size(const LinphoneContent *content) { const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); size_t size = 0; if (c->isFile()) size = static_cast(c)->getFileSize(); else if (c->isFileTransfer()) size = static_cast(c)->getFileSize(); + return size; +} - if (size == 0) { - size = c->getSize(); - } +size_t linphone_content_get_size (const LinphoneContent *content) { + const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); + size_t size = c->getSize(); if (size == 0) { size = content->size; }