Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblinphone
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
10
Issues
10
List
Board
Labels
Milestones
Merge Requests
23
Merge Requests
23
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
liblinphone
Commits
3fd55c4a
Commit
3fd55c4a
authored
Mar 15, 2018
by
Sylvain Berfini
🎩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes + tests for external body URL
parent
166b0a5d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
3 deletions
+58
-3
c-chat-room.cpp
src/c-wrapper/api/c-chat-room.cpp
+6
-1
chat-message.cpp
src/chat/chat-message/chat-message.cpp
+2
-2
chat-room.cpp
src/chat/chat-room/chat-room.cpp
+2
-0
message_tester.c
tester/message_tester.c
+48
-0
No files found.
src/c-wrapper/api/c-chat-room.cpp
View file @
3fd55c4a
...
...
@@ -113,7 +113,12 @@ const LinphoneAddress *linphone_chat_room_get_local_address (LinphoneChatRoom *c
}
LinphoneChatMessage
*
linphone_chat_room_create_message
(
LinphoneChatRoom
*
cr
,
const
char
*
message
)
{
shared_ptr
<
LinphonePrivate
::
ChatMessage
>
cppPtr
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
createChatMessage
(
L_C_TO_STRING
(
message
));
shared_ptr
<
LinphonePrivate
::
ChatMessage
>
cppPtr
;
if
(
message
&&
strlen
(
message
)
>
0
)
{
cppPtr
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
createChatMessage
(
L_C_TO_STRING
(
message
));
}
else
{
cppPtr
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
createChatMessage
();
}
LinphoneChatMessage
*
object
=
L_INIT
(
ChatMessage
);
L_SET_CPP_PTR_FROM_C_OBJECT
(
object
,
cppPtr
);
return
object
;
...
...
src/chat/chat-message/chat-message.cpp
View file @
3fd55c4a
...
...
@@ -722,7 +722,7 @@ void ChatMessagePrivate::send () {
if
(
internalContent
.
isEmpty
())
{
if
(
contents
.
size
()
>
0
)
{
internalContent
=
*
(
contents
.
front
());
}
else
if
(
!
externalBodyUrl
.
empty
())
{
// When using external body url, there is no content
}
else
if
(
externalBodyUrl
.
empty
())
{
// When using external body url, there is no content
lError
()
<<
"Trying to send a message without any content !"
;
return
;
}
...
...
@@ -730,7 +730,7 @@ void ChatMessagePrivate::send () {
auto
msgOp
=
dynamic_cast
<
SalMessageOpInterface
*>
(
op
);
if
(
!
externalBodyUrl
.
empty
())
{
char
*
content_type
=
ms_strdup_printf
(
"message/external-body; access-type=URL; URL=
\"
%s
\"
"
,
externalBodyUrl
);
char
*
content_type
=
ms_strdup_printf
(
"message/external-body; access-type=URL; URL=
\"
%s
\"
"
,
externalBodyUrl
.
c_str
()
);
msgOp
->
send_message
(
content_type
,
NULL
);
ms_free
(
content_type
);
}
else
if
(
internalContent
.
getContentType
().
isValid
())
{
...
...
src/chat/chat-room/chat-room.cpp
View file @
3fd55c4a
...
...
@@ -26,6 +26,7 @@
#include "chat/chat-room/chat-room-p.h"
#include "core/core-p.h"
#include "sip-tools/sip-headers.h"
#include "logger/logger.h"
// =============================================================================
...
...
@@ -194,6 +195,7 @@ LinphoneReason ChatRoomPrivate::onSipMessageReceived (SalOp *op, const SalMessag
Content
content
;
if
(
message
->
url
&&
strcmp
(
message
->
content_type
,
ContentType
::
ExternalBody
.
asString
().
c_str
())
==
0
)
{
lInfo
()
<<
"Received a message with an external body URL "
<<
message
->
url
;
content
.
setContentType
(
ContentType
::
FileTransfer
);
content
.
setBody
(
msg
->
getPrivate
()
->
createFakeFileTransferFromUrl
(
message
->
url
));
}
else
{
...
...
tester/message_tester.c
View file @
3fd55c4a
...
...
@@ -730,6 +730,52 @@ static void file_transfer_2_messages_simultaneously(void) {
}
}
static
void
file_transfer_external_body_url
(
bool_t
use_file_body_handler_in_download
)
{
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
"pauline_tcp_rc"
);
LinphoneChatRoom
*
chat_room
=
linphone_core_get_chat_room
(
marie
->
lc
,
pauline
->
identity
);
LinphoneChatMessage
*
msg
=
linphone_chat_room_create_message
(
chat_room
,
NULL
);
LinphoneChatMessageCbs
*
cbs
=
linphone_chat_message_get_callbacks
(
msg
);
char
*
receive_filepath
=
bc_tester_file
(
"receive_file.dump"
);
linphone_chat_message_set_external_body_url
(
msg
,
"https://www.linphone.org/img/linphone-open-source-voip-projectX2.png"
);
linphone_chat_message_cbs_set_msg_state_changed
(
cbs
,
liblinphone_tester_chat_message_msg_state_changed
);
linphone_chat_room_send_chat_message
(
chat_room
,
msg
);
linphone_chat_message_unref
(
msg
);
BC_ASSERT_TRUE
(
wait_for_until
(
pauline
->
lc
,
marie
->
lc
,
&
pauline
->
stat
.
number_of_LinphoneMessageReceivedWithFile
,
1
,
60000
));
if
(
pauline
->
stat
.
last_received_chat_message
)
{
LinphoneChatMessage
*
recv_msg
=
pauline
->
stat
.
last_received_chat_message
;
cbs
=
linphone_chat_message_get_callbacks
(
recv_msg
);
linphone_chat_message_cbs_set_msg_state_changed
(
cbs
,
liblinphone_tester_chat_message_msg_state_changed
);
linphone_chat_message_cbs_set_file_transfer_recv
(
cbs
,
file_transfer_received
);
linphone_chat_message_cbs_set_file_transfer_progress_indication
(
cbs
,
file_transfer_progress_indication
);
if
(
use_file_body_handler_in_download
)
{
/* Remove any previously downloaded file */
remove
(
receive_filepath
);
linphone_chat_message_set_file_transfer_filepath
(
recv_msg
,
receive_filepath
);
}
linphone_chat_message_download_file
(
recv_msg
);
/* wait for a long time in case the DNS SRV resolution takes times - it should be immediate though */
BC_ASSERT_TRUE
(
wait_for_until
(
pauline
->
lc
,
marie
->
lc
,
&
pauline
->
stat
.
number_of_LinphoneFileTransferDownloadSuccessful
,
1
,
55000
));
}
remove
(
receive_filepath
);
bc_free
(
receive_filepath
);
linphone_core_manager_destroy
(
marie
);
linphone_core_manager_destroy
(
pauline
);
}
static
void
file_transfer_using_external_body_url
(
void
)
{
file_transfer_external_body_url
(
FALSE
);
}
static
void
file_transfer_using_external_body_url_2
(
void
)
{
file_transfer_external_body_url
(
TRUE
);
}
static
void
text_message_denied
(
void
)
{
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
"pauline_tcp_rc"
);
...
...
@@ -2439,6 +2485,8 @@ test_t message_tests[] = {
TEST_NO_TAG
(
"Transfer message upload cancelled"
,
transfer_message_upload_cancelled
),
TEST_NO_TAG
(
"Transfer message download cancelled"
,
transfer_message_download_cancelled
),
TEST_NO_TAG
(
"Transfer 2 messages simultaneously"
,
file_transfer_2_messages_simultaneously
),
TEST_NO_TAG
(
"Transfer using external body URL"
,
file_transfer_using_external_body_url
),
TEST_NO_TAG
(
"Transfer using external body URL 2"
,
file_transfer_using_external_body_url_2
),
TEST_NO_TAG
(
"Text message denied"
,
text_message_denied
),
TEST_NO_TAG
(
"IsComposing notification"
,
is_composing_notification
),
TEST_NO_TAG
(
"IMDN notifications"
,
imdn_notifications
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment