mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
fix(core): fix downloadFile method, returns bool instead of int! There is no reason to return -1 on error like a C function
This commit is contained in:
parent
b001af3784
commit
3dede7ccda
7 changed files with 84 additions and 78 deletions
|
|
@ -4689,10 +4689,10 @@ extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setFileTransferFi
|
|||
ReleaseStringUTFChars(env, jpath, path);
|
||||
}
|
||||
|
||||
extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_downloadFile(JNIEnv* env
|
||||
extern "C" jboolean Java_org_linphone_core_LinphoneChatMessageImpl_downloadFile(JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong ptr) {
|
||||
return (jint) linphone_chat_message_download_file((LinphoneChatMessage*)ptr);
|
||||
return linphone_chat_message_download_file((LinphoneChatMessage*)ptr);
|
||||
}
|
||||
|
||||
extern "C" jboolean Java_org_linphone_core_LinphoneChatMessageImpl_isSecured(JNIEnv* env
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_message_start_file_downlo
|
|||
* Start the download of the file referenced in a #LinphoneChatMessage from remote server.
|
||||
* @param[in] msg #LinphoneChatMessage object.
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneStatus linphone_chat_message_download_file (LinphoneChatMessage *msg);
|
||||
LINPHONE_PUBLIC bool_t linphone_chat_message_download_file (LinphoneChatMessage *msg);
|
||||
|
||||
/**
|
||||
* Cancel an ongoing file transfer attached to this message.(upload or download)
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ public interface LinphoneChatMessage {
|
|||
/**
|
||||
* Start the download of the file referenced in a LinphoneChatMessage from remote server.
|
||||
*/
|
||||
int downloadFile();
|
||||
boolean downloadFile();
|
||||
|
||||
/**
|
||||
* Set the callbacks associated with the LinphoneChatMessage.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
|
|||
private native void store(long ptr);
|
||||
private native int getStorageId(long ptr);
|
||||
private native void setFileTransferFilepath(long ptr, String path);
|
||||
private native int downloadFile(long ptr);
|
||||
private native boolean downloadFile(long ptr);
|
||||
private native void setListener(long ptr, LinphoneChatMessageListener listener);
|
||||
private native void unref(long ptr);
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int downloadFile() {
|
||||
public boolean downloadFile() {
|
||||
return downloadFile(nativePtr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,69 +104,69 @@ LinphoneChatMessageCbs *linphone_chat_message_get_callbacks(const LinphoneChatMe
|
|||
// Getter and setters
|
||||
// =============================================================================
|
||||
|
||||
LinphoneChatRoom *linphone_chat_message_get_chat_room(const LinphoneChatMessage *msg) {
|
||||
LinphoneChatRoom *linphone_chat_message_get_chat_room (const LinphoneChatMessage *msg) {
|
||||
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getChatRoom());
|
||||
}
|
||||
|
||||
const char *linphone_chat_message_get_external_body_url(const LinphoneChatMessage *msg) {
|
||||
const char *linphone_chat_message_get_external_body_url (const LinphoneChatMessage *msg) {
|
||||
return L_STRING_TO_C(L_GET_PRIVATE_FROM_C_OBJECT(msg)->getExternalBodyUrl());
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_external_body_url(LinphoneChatMessage *msg, const char *url) {
|
||||
void linphone_chat_message_set_external_body_url (LinphoneChatMessage *msg, const char *url) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setExternalBodyUrl(L_C_TO_STRING(url));
|
||||
}
|
||||
|
||||
time_t linphone_chat_message_get_time(const LinphoneChatMessage *msg) {
|
||||
time_t linphone_chat_message_get_time (const LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getTime();
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_is_secured(LinphoneChatMessage *msg) {
|
||||
bool_t linphone_chat_message_is_secured (LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isSecured();
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_is_outgoing(LinphoneChatMessage *msg) {
|
||||
bool_t linphone_chat_message_is_outgoing (LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getDirection() == LinphonePrivate::ChatMessage::Direction::Outgoing;
|
||||
}
|
||||
|
||||
LinphoneChatMessageState linphone_chat_message_get_state(const LinphoneChatMessage *msg) {
|
||||
LinphoneChatMessageState linphone_chat_message_get_state (const LinphoneChatMessage *msg) {
|
||||
return ((LinphoneChatMessageState)L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getState());
|
||||
}
|
||||
|
||||
const char* linphone_chat_message_get_message_id(const LinphoneChatMessage *msg) {
|
||||
const char* linphone_chat_message_get_message_id (const LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getImdnMessageId().c_str();
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_is_read(LinphoneChatMessage *msg) {
|
||||
bool_t linphone_chat_message_is_read (LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isRead();
|
||||
}
|
||||
|
||||
const char *linphone_chat_message_get_appdata(const LinphoneChatMessage *msg) {
|
||||
const char *linphone_chat_message_get_appdata (const LinphoneChatMessage *msg) {
|
||||
return L_STRING_TO_C(L_GET_PRIVATE_FROM_C_OBJECT(msg)->getAppdata());
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_appdata(LinphoneChatMessage *msg, const char *data) {
|
||||
void linphone_chat_message_set_appdata (LinphoneChatMessage *msg, const char *data) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setAppdata(L_C_TO_STRING(data));
|
||||
}
|
||||
|
||||
const LinphoneAddress *linphone_chat_message_get_from_address(LinphoneChatMessage *msg) {
|
||||
const LinphoneAddress *linphone_chat_message_get_from_address (LinphoneChatMessage *msg) {
|
||||
if (msg->from)
|
||||
linphone_address_unref(msg->from);
|
||||
msg->from = linphone_address_new(L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getFromAddress().asString().c_str());
|
||||
return msg->from;
|
||||
}
|
||||
|
||||
const LinphoneAddress *linphone_chat_message_get_to_address(LinphoneChatMessage *msg) {
|
||||
const LinphoneAddress *linphone_chat_message_get_to_address (LinphoneChatMessage *msg) {
|
||||
if (msg->to)
|
||||
linphone_address_unref(msg->to);
|
||||
msg->to = linphone_address_new(L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getToAddress().asString().c_str());
|
||||
return msg->to;
|
||||
}
|
||||
|
||||
const char *linphone_chat_message_get_file_transfer_filepath(LinphoneChatMessage *msg) {
|
||||
const char *linphone_chat_message_get_file_transfer_filepath (LinphoneChatMessage *msg) {
|
||||
return L_STRING_TO_C(L_GET_PRIVATE_FROM_C_OBJECT(msg)->getFileTransferFilepath());
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_file_transfer_filepath(LinphoneChatMessage *msg, const char *filepath) {
|
||||
void linphone_chat_message_set_file_transfer_filepath (LinphoneChatMessage *msg, const char *filepath) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setFileTransferFilepath(L_C_TO_STRING(filepath));
|
||||
}
|
||||
|
||||
|
|
@ -178,24 +178,24 @@ void linphone_chat_message_add_custom_header(
|
|||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->addSalCustomHeader(L_C_TO_STRING(header_name), L_C_TO_STRING(header_value));
|
||||
}
|
||||
|
||||
void linphone_chat_message_remove_custom_header(LinphoneChatMessage *msg, const char *header_name) {
|
||||
void linphone_chat_message_remove_custom_header (LinphoneChatMessage *msg, const char *header_name) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->removeSalCustomHeader(L_C_TO_STRING(header_name));
|
||||
}
|
||||
|
||||
const char *linphone_chat_message_get_custom_header(LinphoneChatMessage *msg, const char *header_name) {
|
||||
const char *linphone_chat_message_get_custom_header (LinphoneChatMessage *msg, const char *header_name) {
|
||||
msg->cache.customHeaderValue = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getSalCustomHeaderValue(L_C_TO_STRING(header_name));
|
||||
return L_STRING_TO_C(msg->cache.customHeaderValue);
|
||||
}
|
||||
|
||||
const LinphoneErrorInfo *linphone_chat_message_get_error_info(const LinphoneChatMessage *msg) {
|
||||
const LinphoneErrorInfo *linphone_chat_message_get_error_info (const LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getErrorInfo();
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_get_to_be_stored(const LinphoneChatMessage *message) {
|
||||
bool_t linphone_chat_message_get_to_be_stored (const LinphoneChatMessage *message) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(message)->getToBeStored();
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_to_be_stored(LinphoneChatMessage *message, bool_t to_be_stored) {
|
||||
void linphone_chat_message_set_to_be_stored (LinphoneChatMessage *message, bool_t to_be_stored) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(message)->setToBeStored(!!to_be_stored);
|
||||
}
|
||||
|
||||
|
|
@ -203,11 +203,11 @@ void linphone_chat_message_set_to_be_stored(LinphoneChatMessage *message, bool_t
|
|||
// Methods
|
||||
// =============================================================================
|
||||
|
||||
LinphoneStatus linphone_chat_message_download_file(LinphoneChatMessage *msg) {
|
||||
return ((LinphoneStatus)L_GET_PRIVATE_FROM_C_OBJECT(msg)->downloadFile());
|
||||
bool_t linphone_chat_message_download_file (LinphoneChatMessage *msg) {
|
||||
return !!L_GET_PRIVATE_FROM_C_OBJECT(msg)->downloadFile();
|
||||
}
|
||||
|
||||
void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
|
||||
void linphone_chat_message_cancel_file_transfer (LinphoneChatMessage *msg) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->cancelFileTransfer();
|
||||
}
|
||||
|
||||
|
|
@ -215,19 +215,19 @@ void linphone_chat_message_send (LinphoneChatMessage *msg) {
|
|||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->send();
|
||||
}
|
||||
|
||||
void linphone_chat_message_resend(LinphoneChatMessage *msg) {
|
||||
void linphone_chat_message_resend (LinphoneChatMessage *msg) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->send();
|
||||
}
|
||||
|
||||
void linphone_chat_message_resend_2(LinphoneChatMessage *msg) {
|
||||
void linphone_chat_message_resend_2 (LinphoneChatMessage *msg) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->send();
|
||||
}
|
||||
|
||||
LinphoneStatus linphone_chat_message_put_char(LinphoneChatMessage *msg, uint32_t character) {
|
||||
LinphoneStatus linphone_chat_message_put_char (LinphoneChatMessage *msg, uint32_t character) {
|
||||
return ((LinphoneStatus)L_GET_CPP_PTR_FROM_C_OBJECT(msg)->putCharacter(character));
|
||||
}
|
||||
|
||||
void linphone_chat_message_add_text_content(LinphoneChatMessage *msg, const char *c_content) {
|
||||
void linphone_chat_message_add_text_content (LinphoneChatMessage *msg, const char *c_content) {
|
||||
LinphonePrivate::Content *content = new LinphonePrivate::Content();
|
||||
LinphonePrivate::ContentType contentType = LinphonePrivate::ContentType::PlainText;
|
||||
content->setContentType(contentType);
|
||||
|
|
@ -235,11 +235,11 @@ void linphone_chat_message_add_text_content(LinphoneChatMessage *msg, const char
|
|||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->addContent(content);
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_has_text_content(const LinphoneChatMessage *msg) {
|
||||
bool_t linphone_chat_message_has_text_content (const LinphoneChatMessage *msg) {
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->hasTextContent();
|
||||
}
|
||||
|
||||
const char *linphone_chat_message_get_text_content(const LinphoneChatMessage *msg) {
|
||||
const char *linphone_chat_message_get_text_content (const LinphoneChatMessage *msg) {
|
||||
const LinphonePrivate::Content *content = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getTextContent();
|
||||
if (content->isEmpty())
|
||||
return nullptr;
|
||||
|
|
@ -247,7 +247,7 @@ const char *linphone_chat_message_get_text_content(const LinphoneChatMessage *ms
|
|||
return L_STRING_TO_C(msg->cache.textContentBody);
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_is_file_transfer_in_progress(LinphoneChatMessage *msg) {
|
||||
bool_t linphone_chat_message_is_file_transfer_in_progress (LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isFileTransferInProgress();
|
||||
}
|
||||
|
||||
|
|
@ -264,15 +264,15 @@ LinphoneChatMessageStateChangedCb linphone_chat_message_get_message_state_change
|
|||
return msg->message_state_changed_cb;
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_message_state_changed_cb(LinphoneChatMessage* msg, LinphoneChatMessageStateChangedCb cb) {
|
||||
void linphone_chat_message_set_message_state_changed_cb (LinphoneChatMessage* msg, LinphoneChatMessageStateChangedCb cb) {
|
||||
msg->message_state_changed_cb = cb;
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_message_state_changed_cb_user_data(LinphoneChatMessage* msg, void *user_data) {
|
||||
void linphone_chat_message_set_message_state_changed_cb_user_data (LinphoneChatMessage* msg, void *user_data) {
|
||||
msg->message_state_changed_user_data = user_data;
|
||||
}
|
||||
|
||||
void * linphone_chat_message_get_message_state_changed_cb_user_data(LinphoneChatMessage* msg) {
|
||||
void * linphone_chat_message_get_message_state_changed_cb_user_data (LinphoneChatMessage* msg) {
|
||||
return msg->message_state_changed_user_data;
|
||||
}
|
||||
|
||||
|
|
@ -280,25 +280,25 @@ void * linphone_chat_message_get_message_state_changed_cb_user_data(LinphoneChat
|
|||
// Structure has changed, hard to keep the behavior
|
||||
// =============================================================================
|
||||
|
||||
const char *linphone_chat_message_get_content_type(LinphoneChatMessage *msg) {
|
||||
const char *linphone_chat_message_get_content_type (LinphoneChatMessage *msg) {
|
||||
msg->cache.contentType = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getContentType().asString();
|
||||
return L_STRING_TO_C(msg->cache.contentType);
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_content_type(LinphoneChatMessage *msg, const char *content_type) {
|
||||
void linphone_chat_message_set_content_type (LinphoneChatMessage *msg, const char *content_type) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setContentType(LinphonePrivate::ContentType(L_C_TO_STRING(content_type)));
|
||||
}
|
||||
|
||||
const char *linphone_chat_message_get_text(LinphoneChatMessage *msg) {
|
||||
const char *linphone_chat_message_get_text (LinphoneChatMessage *msg) {
|
||||
return L_STRING_TO_C(L_GET_PRIVATE_FROM_C_OBJECT(msg)->getText());
|
||||
}
|
||||
|
||||
int linphone_chat_message_set_text(LinphoneChatMessage *msg, const char* text) {
|
||||
int linphone_chat_message_set_text (LinphoneChatMessage *msg, const char* text) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setText(L_C_TO_STRING(text));
|
||||
return 0;
|
||||
}
|
||||
|
||||
LinphoneContent *linphone_chat_message_get_file_transfer_information(LinphoneChatMessage *msg) {
|
||||
LinphoneContent *linphone_chat_message_get_file_transfer_information (LinphoneChatMessage *msg) {
|
||||
const LinphonePrivate::Content *content = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getFileTransferInformation();
|
||||
if (content) return L_GET_C_BACK_PTR(content);
|
||||
return NULL;
|
||||
|
|
@ -308,29 +308,29 @@ LinphoneContent *linphone_chat_message_get_file_transfer_information(LinphoneCha
|
|||
// Nothing to do, they call other C API methods
|
||||
// =============================================================================
|
||||
|
||||
const LinphoneAddress *linphone_chat_message_get_peer_address(LinphoneChatMessage *msg) {
|
||||
const LinphoneAddress *linphone_chat_message_get_peer_address (LinphoneChatMessage *msg) {
|
||||
return linphone_chat_room_get_peer_address(linphone_chat_message_get_chat_room(msg));
|
||||
}
|
||||
|
||||
const LinphoneAddress *linphone_chat_message_get_local_address(LinphoneChatMessage *msg) {
|
||||
const LinphoneAddress *linphone_chat_message_get_local_address (LinphoneChatMessage *msg) {
|
||||
if (L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getDirection() == LinphonePrivate::ChatMessage::Direction::Outgoing)
|
||||
return linphone_chat_message_get_from_address(msg);
|
||||
return linphone_chat_message_get_to_address(msg);
|
||||
}
|
||||
|
||||
LinphoneReason linphone_chat_message_get_reason(LinphoneChatMessage *msg) {
|
||||
LinphoneReason linphone_chat_message_get_reason (LinphoneChatMessage *msg) {
|
||||
return linphone_error_info_get_reason(linphone_chat_message_get_error_info(msg));
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_is_file_transfer(LinphoneChatMessage *msg) {
|
||||
bool_t linphone_chat_message_is_file_transfer (LinphoneChatMessage *msg) {
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->hasFileTransferContent();
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_is_text(LinphoneChatMessage *msg) {
|
||||
bool_t linphone_chat_message_is_text (LinphoneChatMessage *msg) {
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->hasTextContent();
|
||||
}
|
||||
|
||||
const char *linphone_chat_message_state_to_string(const LinphoneChatMessageState state) {
|
||||
const char *linphone_chat_message_state_to_string (const LinphoneChatMessageState state) {
|
||||
switch (state) {
|
||||
case LinphoneChatMessageStateIdle:
|
||||
return "LinphoneChatMessageStateIdle";
|
||||
|
|
@ -352,8 +352,11 @@ const char *linphone_chat_message_state_to_string(const LinphoneChatMessageState
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void linphone_chat_message_start_file_download(LinphoneChatMessage *msg,
|
||||
LinphoneChatMessageStateChangedCb status_cb, void *ud) {
|
||||
void linphone_chat_message_start_file_download (
|
||||
LinphoneChatMessage *msg,
|
||||
LinphoneChatMessageStateChangedCb status_cb,
|
||||
void *ud
|
||||
) {
|
||||
msg->message_state_changed_cb = status_cb;
|
||||
msg->message_state_changed_user_data = ud;
|
||||
linphone_chat_message_download_file(msg);
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h
|
|||
if (c->isFileTransfer()) {
|
||||
FileTransferContent *tmpContent = static_cast<FileTransferContent *>(c);
|
||||
if (!tmpContent->getFileContent() && tmpContent->getSize() == 0) {
|
||||
// If FileTransferContent doesn't have a FileContent yet and is empty
|
||||
// If FileTransferContent doesn't have a FileContent yet and is empty
|
||||
// It's the one we seek, otherwise it may be a previous uploaded FileTransferContent
|
||||
fileTransferContent = tmpContent;
|
||||
break;
|
||||
|
|
@ -546,7 +546,7 @@ void FileTransferChatMessageModifier::fileUploadEndBackgroundTask () {
|
|||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
static void fillFileTransferContentInformationsFromVndGsmaRcsFtHttpXml(FileTransferContent *fileTransferContent) {
|
||||
static void fillFileTransferContentInformationsFromVndGsmaRcsFtHttpXml (FileTransferContent *fileTransferContent) {
|
||||
xmlChar *fileUrl = nullptr;
|
||||
xmlDocPtr xmlMessageBody;
|
||||
xmlNodePtr cur;
|
||||
|
|
@ -947,24 +947,27 @@ void FileTransferChatMessageModifier::processResponseFromGetFile (const belle_ht
|
|||
}
|
||||
}
|
||||
|
||||
int FileTransferChatMessageModifier::downloadFile(const shared_ptr<ChatMessage> &message, FileTransferContent *fileTransferContent) {
|
||||
bool FileTransferChatMessageModifier::downloadFile (
|
||||
const shared_ptr<ChatMessage> &message,
|
||||
FileTransferContent *fileTransferContent
|
||||
) {
|
||||
chatMessage = message;
|
||||
|
||||
if (httpRequest) {
|
||||
lError() << "linphone_chat_message_download_file(): there is already a download in progress";
|
||||
return -1;
|
||||
lError() << "There is already a download in progress.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileTransferContent->getContentType() != ContentType::FileTransfer) {
|
||||
lError() << "linphone_chat_message_download_file(): content type is not FileTransfer";
|
||||
return -1;
|
||||
lError() << "Content type is not a FileTransfer.";
|
||||
return false;
|
||||
}
|
||||
|
||||
createFileTransferInformationsFromVndGsmaRcsFtHttpXml(fileTransferContent);
|
||||
FileContent *fileContent = fileTransferContent->getFileContent();
|
||||
currentFileContentToTransfer = fileContent;
|
||||
if (!currentFileContentToTransfer)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
// THIS IS ONLY FOR BACKWARD C API COMPAT
|
||||
if (currentFileContentToTransfer->getFilePath().empty() && !message->getPrivate()->getFileTransferFilepath().empty()) {
|
||||
|
|
@ -978,10 +981,10 @@ int FileTransferChatMessageModifier::downloadFile(const shared_ptr<ChatMessage>
|
|||
cbs.process_auth_requested = _chat_message_process_auth_requested_download;
|
||||
int err = startHttpTransfer(fileTransferContent->getFileUrl(), "GET", &cbs); // File URL has been set by createFileTransferInformationsFromVndGsmaRcsFtHttpXml
|
||||
if (err == -1)
|
||||
return -1;
|
||||
return false;
|
||||
// start the download, status is In Progress
|
||||
message->getPrivate()->setState(ChatMessage::State::InProgress);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
|
@ -1024,7 +1027,7 @@ void FileTransferChatMessageModifier::releaseHttpRequest () {
|
|||
}
|
||||
}
|
||||
|
||||
string FileTransferChatMessageModifier::createFakeFileTransferFromUrl(const string &url) {
|
||||
string FileTransferChatMessageModifier::createFakeFileTransferFromUrl (const string &url) {
|
||||
string fileName = url.substr(url.find_last_of("/") + 1);
|
||||
stringstream fakeXml;
|
||||
fakeXml << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
|
||||
|
|
|
|||
|
|
@ -53,25 +53,25 @@ public:
|
|||
void processIoErrorUpload (const belle_sip_io_error_event_t *event);
|
||||
void processAuthRequestedUpload (const belle_sip_auth_event *event);
|
||||
|
||||
void onRecvBody(belle_sip_user_body_handler_t *bh, belle_sip_message_t *m, size_t offset, uint8_t *buffer, size_t size);
|
||||
void onRecvEnd(belle_sip_user_body_handler_t *bh);
|
||||
void processResponseHeadersFromGetFile(const belle_http_response_event_t *event);
|
||||
void processAuthRequestedDownload(const belle_sip_auth_event *event);
|
||||
void processIoErrorDownload(const belle_sip_io_error_event_t *event);
|
||||
void processResponseFromGetFile(const belle_http_response_event_t *event);
|
||||
void onRecvBody (belle_sip_user_body_handler_t *bh, belle_sip_message_t *m, size_t offset, uint8_t *buffer, size_t size);
|
||||
void onRecvEnd (belle_sip_user_body_handler_t *bh);
|
||||
void processResponseHeadersFromGetFile (const belle_http_response_event_t *event);
|
||||
void processAuthRequestedDownload (const belle_sip_auth_event *event);
|
||||
void processIoErrorDownload (const belle_sip_io_error_event_t *event);
|
||||
void processResponseFromGetFile (const belle_http_response_event_t *event);
|
||||
|
||||
int downloadFile(const std::shared_ptr<ChatMessage> &message, FileTransferContent *fileTransferContent);
|
||||
void cancelFileTransfer();
|
||||
bool isFileTransferInProgressAndValid();
|
||||
std::string createFakeFileTransferFromUrl(const std::string &url);
|
||||
bool downloadFile (const std::shared_ptr<ChatMessage> &message, FileTransferContent *fileTransferContent);
|
||||
void cancelFileTransfer ();
|
||||
bool isFileTransferInProgressAndValid ();
|
||||
std::string createFakeFileTransferFromUrl (const std::string &url);
|
||||
|
||||
private:
|
||||
int uploadFile();
|
||||
int startHttpTransfer(const std::string &url, const std::string &action, belle_http_request_listener_callbacks_t *cbs);
|
||||
void fileUploadBeginBackgroundTask();
|
||||
void fileUploadEndBackgroundTask();
|
||||
int uploadFile ();
|
||||
int startHttpTransfer (const std::string &url, const std::string &action, belle_http_request_listener_callbacks_t *cbs);
|
||||
void fileUploadBeginBackgroundTask ();
|
||||
void fileUploadEndBackgroundTask ();
|
||||
|
||||
void releaseHttpRequest();
|
||||
void releaseHttpRequest ();
|
||||
|
||||
std::weak_ptr<ChatMessage> chatMessage;
|
||||
FileContent* currentFileContentToTransfer = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue