chat.c: properly clean filetransfer when it failed for io error and/or server issue

parent fff66504
......@@ -106,26 +106,13 @@ static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatM
static void process_io_error_upload(void *data, const belle_sip_io_error_event_t *event){
LinphoneChatMessage* msg=(LinphoneChatMessage *)data;
msg->state = LinphoneChatMessageStateNotDelivered;
ms_error("I/O Error during file upload to %s - msg [%p] chat room[%p]", linphone_core_get_file_transfer_server(msg->chat_room->lc), msg, msg->chat_room);
if (msg->cb) {
msg->cb(msg, msg->state, msg->cb_ud);
}
if (linphone_chat_message_cbs_get_msg_state_changed(msg->callbacks)) {
linphone_chat_message_cbs_get_msg_state_changed(msg->callbacks)(msg, msg->state);
}
linphone_chat_message_cancel_file_transfer(msg);
}
static void process_auth_requested_upload(void *data, belle_sip_auth_event_t *event){
LinphoneChatMessage* msg=(LinphoneChatMessage *)data;
msg->state = LinphoneChatMessageStateNotDelivered;
ms_error("Error during file upload : auth requested to connect %s - msg [%p] chat room[%p]", linphone_core_get_file_transfer_server(msg->chat_room->lc), msg, msg->chat_room);
if (msg->cb) {
msg->cb(msg, msg->state, msg->cb_ud);
}
if (linphone_chat_message_cbs_get_msg_state_changed(msg->callbacks)) {
linphone_chat_message_cbs_get_msg_state_changed(msg->callbacks)(msg, msg->state);
}
ms_error("Error during file upload: auth requested to connect %s - msg [%p] chat room[%p]", linphone_core_get_file_transfer_server(msg->chat_room->lc), msg, msg->chat_room);
linphone_chat_message_cancel_file_transfer(msg);
}
static void process_io_error_download(void *data, const belle_sip_io_error_event_t *event){
......@@ -1404,7 +1391,6 @@ static void _linphone_chat_message_destroy(LinphoneChatMessage* msg) {
ms_free(msg->file_transfer_filepath);
}
linphone_chat_message_cbs_unref(msg->callbacks);
ms_message("LinphoneChatMessage [%p] destroyed.",msg);
}
LinphoneChatMessage * linphone_chat_message_ref(LinphoneChatMessage *msg){
......@@ -1440,7 +1426,7 @@ LinphoneChatMessageCbs * linphone_chat_message_get_callbacks(const LinphoneChatM
return msg->callbacks;
}
LinphoneChatMessage* linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr, LinphoneContent* initial_content) {
LinphoneChatMessage* linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr, const LinphoneContent* initial_content) {
LinphoneChatMessage* msg = belle_sip_object_new(LinphoneChatMessage);
msg->callbacks=linphone_chat_message_cbs_new();
msg->chat_room=(LinphoneChatRoom*)cr;
......
......@@ -905,7 +905,7 @@ LINPHONE_PUBLIC void linphone_call_set_audio_route(LinphoneCall *call, LinphoneA
* Returns the number of stream for the given call.
* Currently there is only two (Audio, Video), but later there will be more.
* @param call
*
*
* @return 2
**/
LINPHONE_PUBLIC int linphone_call_get_stream_count(LinphoneCall *call);
......@@ -914,7 +914,7 @@ LINPHONE_PUBLIC int linphone_call_get_stream_count(LinphoneCall *call);
* Returns the type of stream for the given stream index.
* @param call
* @param stream_index
*
*
* @return MsAudio if stream_index = 0, MsVideo otherwise
**/
LINPHONE_PUBLIC MSFormatType linphone_call_get_stream_type(LinphoneCall *call, int stream_index);
......@@ -923,7 +923,7 @@ LINPHONE_PUBLIC MSFormatType linphone_call_get_stream_type(LinphoneCall *call, i
* Returns the meta rtp transport for the given stream index.
* @param call
* @param stream_index
*
*
* @return a pointer to the meta rtp transport if it exists, NULL otherwise
**/
LINPHONE_PUBLIC RtpTransport* linphone_call_get_meta_rtp_transport(LinphoneCall *call, int stream_index);
......@@ -932,7 +932,7 @@ LINPHONE_PUBLIC RtpTransport* linphone_call_get_meta_rtp_transport(LinphoneCall
* Returns the meta rtcp transport for the given stream index.
* @param call
* @param stream_index
*
*
* @return a pointer to the meta rtcp transport if it exists, NULL otherwise
**/
LINPHONE_PUBLIC RtpTransport* linphone_call_get_meta_rtcp_transport(LinphoneCall *call, int stream_index);
......@@ -1333,17 +1333,17 @@ LINPHONE_PUBLIC void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void
/**
* Create a message attached to a dedicated chat room with a particular content.
* Use #linphone_chat_room_send_message2 to initiate the transfer
* Use #linphone_chat_room_send_message to initiate the transfer
* @param cr the chat room.
* @param initial_content #LinphoneContent initial content. #LinphoneCoreVTable.file_transfer_send is invoked later to notify file transfer progress and collect next chunk of the message if #LinphoneContent.data is NULL.
* @return a new #LinphoneChatMessage
*/
LINPHONE_PUBLIC LinphoneChatMessage* linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr, LinphoneContent* initial_content);
LINPHONE_PUBLIC LinphoneChatMessage* linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr, const LinphoneContent* initial_content);
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_room_get_peer_address(LinphoneChatRoom *cr);
/**
* Send a message to peer member of this chat room.
* @deprecated linphone_chat_room_send_message2() gives more control on the message expedition.
* @deprecated Use linphone_chat_room_send_chat_message() instead.
* @param cr #LinphoneChatRoom object
* @param msg message to be sent
*/
......
......@@ -116,7 +116,7 @@ static int callback_all(void *data, int argc, char **argv, char **colName){
* | 8 | external body url
* | 9 | utc timestamp
* | 10 | app data text
* | 11 | linphone content
* | 11 | linphone content id
*/
static int create_chat_message(void *data, int argc, char **argv, char **colName){
LinphoneChatRoom *cr = (LinphoneChatRoom *)data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment