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
22
Merge Requests
22
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
f117ff95
Commit
f117ff95
authored
Nov 16, 2017
by
Ghislain MARY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix chat related code that was broken with the introduction of ChatRoomId.
parent
a39d7d01
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
63 additions
and
63 deletions
+63
-63
callbacks.c
coreapi/callbacks.c
+6
-8
chat.c
coreapi/chat.c
+12
-6
linphonecore.c
coreapi/linphonecore.c
+13
-14
tester_utils.cpp
coreapi/tester_utils.cpp
+8
-7
tester_utils.h
coreapi/tester_utils.h
+1
-1
chat-message-p.h
src/chat/chat-message/chat-message-p.h
+5
-0
chat-message.cpp
src/chat/chat-message/chat-message.cpp
+10
-15
chat-message.h
src/chat/chat-message/chat-message.h
+2
-8
chat-room.cpp
src/chat/chat-room/chat-room.cpp
+3
-3
core-chat-room.cpp
src/core/core-chat-room.cpp
+3
-1
No files found.
coreapi/callbacks.c
View file @
f117ff95
...
...
@@ -129,7 +129,7 @@ static void call_received(SalCallOp *h) {
linphone_address_unref
(
toAddr
);
linphone_address_unref
(
fromAddr
);
shared_ptr
<
ChatRoom
>
chatRoom
=
lc
->
cppCore
->
findChatRoom
(
ChatRoomId
(
SimpleAddress
(
h
->
get_to
()),
SimpleAddress
(
h
->
get_
from
()))
ChatRoomId
(
SimpleAddress
(
h
->
get_to
()),
SimpleAddress
(
h
->
get_
to
()))
);
if
(
chatRoom
)
{
L_GET_PRIVATE
(
static_pointer_cast
<
ServerGroupChatRoom
>
(
chatRoom
))
->
confirmJoining
(
h
);
...
...
@@ -753,10 +753,10 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
if
(
linphone_core_conference_server_enabled
(
lc
))
{
// Removal of a participant at the server side
shared_ptr
<
ChatRoom
>
chatRoom
=
lc
->
cppCore
->
findChatRoom
(
ChatRoomId
(
SimpleAddress
(
op
->
get_to
()),
SimpleAddress
(
op
->
get_
from
()))
ChatRoomId
(
SimpleAddress
(
op
->
get_to
()),
SimpleAddress
(
op
->
get_
to
()))
);
if
(
chatRoom
)
{
std
::
shared_ptr
<
Participant
>
participant
=
chatRoom
->
findParticipant
(
chatRoom
->
getLocalAddress
(
));
std
::
shared_ptr
<
Participant
>
participant
=
chatRoom
->
findParticipant
(
SimpleAddress
(
op
->
get_from
()
));
if
(
!
participant
||
!
participant
->
isAdmin
())
{
static_cast
<
SalReferOp
*>
(
op
)
->
reply
(
SalReasonDeclined
);
return
;
...
...
@@ -770,7 +770,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
}
else
{
// The server asks a participant to leave a chat room
LinphoneChatRoom
*
cr
=
L_GET_C_BACK_PTR
(
lc
->
cppCore
->
findChatRoom
(
ChatRoomId
(
addr
,
SimpleAddress
(
op
->
get_
from
())))
lc
->
cppCore
->
findChatRoom
(
ChatRoomId
(
addr
,
SimpleAddress
(
op
->
get_
to
())))
);
if
(
cr
)
{
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
leave
();
...
...
@@ -781,7 +781,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
}
}
else
if
(
addr
.
hasParam
(
"admin"
))
{
LinphoneChatRoom
*
cr
=
L_GET_C_BACK_PTR
(
lc
->
cppCore
->
findChatRoom
(
ChatRoomId
(
SimpleAddress
(
op
->
get_to
()),
SimpleAddress
(
op
->
get_
from
()))
ChatRoomId
(
SimpleAddress
(
op
->
get_to
()),
SimpleAddress
(
op
->
get_
to
()))
));
if
(
cr
)
{
Address
fromAddr
(
op
->
get_from
());
...
...
@@ -799,9 +799,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
return
;
}
}
else
{
LinphoneChatRoom
*
cr
=
L_GET_C_BACK_PTR
(
lc
->
cppCore
->
findChatRoom
(
ChatRoomId
(
addr
,
SimpleAddress
(
op
->
get_from
()))
));
LinphoneChatRoom
*
cr
=
L_GET_C_BACK_PTR
(
lc
->
cppCore
->
findChatRoom
(
ChatRoomId
(
addr
,
SimpleAddress
(
op
->
get_to
()))));
if
(
!
cr
)
cr
=
_linphone_client_group_chat_room_new
(
lc
,
addr
.
asString
().
c_str
(),
nullptr
);
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
join
();
...
...
coreapi/chat.c
View file @
f117ff95
...
...
@@ -111,15 +111,21 @@ LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const c
int
linphone_core_message_received
(
LinphoneCore
*
lc
,
LinphonePrivate
::
SalOp
*
op
,
const
SalMessage
*
sal_msg
)
{
LinphoneReason
reason
=
LinphoneReasonNotAcceptable
;
const
char
*
peerAddress
=
linphone_core_conference_server_enabled
(
lc
)
?
op
->
get_to
()
:
op
->
get_from
();
const
char
*
peerAddress
;
const
char
*
localAddress
;
if
(
linphone_core_conference_server_enabled
(
lc
))
{
localAddress
=
peerAddress
=
op
->
get_to
();
}
else
{
peerAddress
=
op
->
get_from
();
localAddress
=
op
->
get_to
();
}
// TODO: Use local address.
list
<
shared_ptr
<
LinphonePrivate
::
ChatRoom
>>
chatRooms
=
lc
->
cppCore
->
findChatRooms
(
LinphonePrivate
::
SimpleAddress
(
peerAddress
)
shared_ptr
<
LinphonePrivate
::
ChatRoom
>
chatRoom
=
lc
->
cppCore
->
findChatRoom
(
LinphonePrivate
::
ChatRoomId
(
LinphonePrivate
::
SimpleAddress
(
peerAddress
),
LinphonePrivate
::
SimpleAddress
(
localAddress
))
);
if
(
!
chatRooms
.
empty
()
)
reason
=
L_GET_PRIVATE
(
chatRoom
s
.
front
()
)
->
messageReceived
(
op
,
sal_msg
);
if
(
chatRoom
)
reason
=
L_GET_PRIVATE
(
chatRoom
)
->
messageReceived
(
op
,
sal_msg
);
else
{
LinphoneAddress
*
addr
=
linphone_address_new
(
sal_msg
->
from
);
linphone_address_clean
(
addr
);
...
...
coreapi/linphonecore.c
View file @
f117ff95
...
...
@@ -2135,16 +2135,17 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
}
}
else
if
(
strcmp
(
notified_event
,
"conference"
)
==
0
)
{
const
LinphoneAddress
*
resource
=
linphone_event_get_resource
(
lev
);
const
LinphoneAddress
*
from
=
linphone_event_get_from
(
lev
);
// TODO: Ensure it is the good solution.
list
<
shared_ptr
<
ChatRoom
>>
chatRooms
=
lc
->
cppCore
->
findChatRooms
(
SimpleAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
resource
))
);
shared_ptr
<
ChatRoom
>
chatRoom
=
lc
->
cppCore
->
findChatRoom
(
LinphonePrivate
::
ChatRoomId
(
SimpleAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
resource
)),
SimpleAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
from
))
)
)
;
if
(
!
chatRooms
.
empty
()
)
L_GET_PRIVATE
(
static_pointer_cast
<
ClientGroupChatRoom
>
(
chatRoom
s
.
front
()
))
->
notifyReceived
(
if
(
chatRoom
)
L_GET_PRIVATE
(
static_pointer_cast
<
ClientGroupChatRoom
>
(
chatRoom
))
->
notifyReceived
(
linphone_content_get_string_buffer
(
body
)
);
);
}
}
...
...
@@ -2154,15 +2155,13 @@ static void _linphone_core_conference_subscription_state_changed(LinphoneCore *l
state
==
LinphoneSubscriptionIncomingReceived
)
{
const
LinphoneAddress
*
resource
=
linphone_event_get_resource
(
lev
);
// TODO: Ensure it is the good solution.
list
<
shared_ptr
<
ChatRoom
>>
chatRooms
=
lc
->
cppCore
->
findChatRooms
(
shared_ptr
<
ChatRoom
>
chatRoom
=
lc
->
cppCore
->
findChatRoom
(
LinphonePrivate
::
ChatRoomId
(
SimpleAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
resource
)),
SimpleAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
resource
))
);
if
(
!
chatRooms
.
empty
())
{
));
if
(
chatRoom
)
{
linphone_event_accept_subscription
(
lev
);
L_GET_PRIVATE
(
static_pointer_cast
<
ServerGroupChatRoom
>
(
chatRoom
s
.
front
()
))
->
subscribeReceived
(
lev
);
L_GET_PRIVATE
(
static_pointer_cast
<
ServerGroupChatRoom
>
(
chatRoom
))
->
subscribeReceived
(
lev
);
}
else
linphone_event_deny_subscription
(
lev
,
LinphoneReasonDeclined
);
}
...
...
coreapi/tester_utils.cpp
View file @
f117ff95
...
...
@@ -56,13 +56,14 @@ bctbx_list_t **linphone_core_get_call_logs_attribute(LinphoneCore *lc) {
return
&
lc
->
call_logs
;
}
LinphoneChatRoom
*
linphone_core_find_chat_room
(
const
LinphoneCore
*
lc
,
const
LinphoneAddress
*
addr
)
{
list
<
shared_ptr
<
ChatRoom
>>
chatRooms
=
lc
->
cppCore
->
findChatRooms
(
SimpleAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
addr
))
);
if
(
!
chatRooms
.
empty
())
return
L_GET_C_BACK_PTR
(
chatRooms
.
front
());
LinphoneChatRoom
*
linphone_core_find_chat_room
(
const
LinphoneCore
*
lc
,
const
LinphoneAddress
*
peerAddr
,
const
LinphoneAddress
*
localAddr
)
{
shared_ptr
<
ChatRoom
>
chatRoom
=
lc
->
cppCore
->
findChatRoom
(
ChatRoomId
(
SimpleAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
peerAddr
)),
SimpleAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
localAddr
))
));
if
(
chatRoom
)
return
L_GET_C_BACK_PTR
(
chatRoom
);
return
nullptr
;
}
...
...
coreapi/tester_utils.h
View file @
f117ff95
...
...
@@ -94,7 +94,7 @@ LINPHONE_PUBLIC LinphoneQualityReporting *linphone_call_log_get_quality_reportin
LINPHONE_PUBLIC
reporting_session_report_t
**
linphone_quality_reporting_get_reports
(
LinphoneQualityReporting
*
qreporting
);
LINPHONE_PUBLIC
bctbx_list_t
*
linphone_chat_room_get_transient_messages
(
const
LinphoneChatRoom
*
cr
);
LINPHONE_PUBLIC
LinphoneChatRoom
*
linphone_core_find_chat_room
(
const
LinphoneCore
*
lc
,
const
LinphoneAddress
*
a
ddr
);
LINPHONE_PUBLIC
LinphoneChatRoom
*
linphone_core_find_chat_room
(
const
LinphoneCore
*
lc
,
const
LinphoneAddress
*
peerAddr
,
const
LinphoneAddress
*
localA
ddr
);
LINPHONE_PUBLIC
MSList
*
linphone_core_fetch_friends_from_db
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
);
LINPHONE_PUBLIC
MSList
*
linphone_core_fetch_friends_lists_from_db
(
LinphoneCore
*
lc
);
...
...
src/chat/chat-message/chat-message-p.h
View file @
f117ff95
...
...
@@ -67,6 +67,10 @@ public:
this
->
fromAddress
=
fromAddress
;
}
inline
void
forceToAddress
(
const
SimpleAddress
&
toAddress
)
{
this
->
toAddress
=
toAddress
;
}
unsigned
int
getStorageId
()
const
;
void
setStorageId
(
unsigned
int
id
);
...
...
@@ -149,6 +153,7 @@ private:
std
::
weak_ptr
<
ChatRoom
>
chatRoom
;
ChatRoomId
chatRoomId
;
SimpleAddress
fromAddress
;
SimpleAddress
toAddress
;
ChatMessage
::
State
state
=
ChatMessage
::
State
::
Idle
;
ChatMessage
::
Direction
direction
=
ChatMessage
::
Direction
::
Incoming
;
...
...
src/chat/chat-message/chat-message.cpp
View file @
f117ff95
...
...
@@ -678,26 +678,21 @@ void ChatMessagePrivate::send () {
// -----------------------------------------------------------------------------
ChatMessage
::
ChatMessage
(
const
shared_ptr
<
ChatRoom
>
&
chatRoom
)
:
ChatMessage
::
ChatMessage
(
const
shared_ptr
<
ChatRoom
>
&
chatRoom
,
ChatMessage
::
Direction
direction
)
:
Object
(
*
new
ChatMessagePrivate
),
CoreAccessor
(
chatRoom
->
getCore
())
{
L_ASSERT
(
chatRoom
);
L_D
();
d
->
chatRoom
=
chatRoom
;
d
->
chatRoomId
=
chatRoom
->
getChatRoomId
();
d
->
fromAddress
=
chatRoom
->
getLocalAddress
();
d
->
direction
=
Direction
::
Outgoing
;
}
ChatMessage
::
ChatMessage
(
const
shared_ptr
<
ChatRoom
>
&
chatRoom
,
const
SimpleAddress
&
fromAddress
)
:
Object
(
*
new
ChatMessagePrivate
),
CoreAccessor
(
chatRoom
->
getCore
())
{
L_ASSERT
(
chatRoom
);
L_D
();
d
->
chatRoom
=
chatRoom
;
d
->
chatRoomId
=
chatRoom
->
getChatRoomId
();
d
->
fromAddress
=
fromAddress
;
d
->
direction
=
Direction
::
Incoming
;
if
(
direction
==
Direction
::
Outgoing
)
{
d
->
fromAddress
=
chatRoom
->
getLocalAddress
();
d
->
toAddress
=
chatRoom
->
getPeerAddress
();
}
else
{
d
->
fromAddress
=
chatRoom
->
getPeerAddress
();
d
->
toAddress
=
chatRoom
->
getLocalAddress
();
}
d
->
direction
=
direction
;
}
ChatMessage
::~
ChatMessage
()
{
...
...
@@ -779,7 +774,7 @@ const SimpleAddress &ChatMessage::getFromAddress () const {
const
SimpleAddress
&
ChatMessage
::
getToAddress
()
const
{
L_D
();
return
d
->
direction
==
Direction
::
Outgoing
?
d
->
chatRoomId
.
getPeerAddress
()
:
d
->
chatRoomId
.
getLocalAddress
()
;
return
d
->
toAddress
;
}
const
SimpleAddress
&
ChatMessage
::
getLocalAddress
()
const
{
...
...
src/chat/chat-message/chat-message.h
View file @
f117ff95
...
...
@@ -55,14 +55,6 @@ public:
L_DECLARE_ENUM
(
State
,
L_ENUM_VALUES_CHAT_MESSAGE_STATE
);
L_DECLARE_ENUM
(
Direction
,
L_ENUM_VALUES_CHAT_MESSAGE_DIRECTION
);
// TODO: Make me private.
// Build an outgoing message.
ChatMessage
(
const
std
::
shared_ptr
<
ChatRoom
>
&
chatRoom
);
// Build and incoming message.
ChatMessage
(
const
std
::
shared_ptr
<
ChatRoom
>
&
chatRoom
,
const
SimpleAddress
&
fromAddress
);
~
ChatMessage
();
// ----- TODO: Remove me.
...
...
@@ -114,6 +106,8 @@ public:
bool
downloadFile
(
FileTransferContent
&
content
);
private
:
ChatMessage
(
const
std
::
shared_ptr
<
ChatRoom
>
&
chatRoom
,
ChatMessage
::
Direction
direction
);
L_DECLARE_PRIVATE
(
ChatMessage
);
L_DISABLE_COPY
(
ChatMessage
);
};
...
...
src/chat/chat-room/chat-room.cpp
View file @
f117ff95
...
...
@@ -151,7 +151,7 @@ void ChatRoomPrivate::sendIsComposingNotification () {
if
(
linphone_im_notif_policy_get_send_is_composing
(
policy
))
{
string
payload
=
isComposingHandler
->
marshal
(
isComposing
);
if
(
!
payload
.
empty
())
{
shared_ptr
<
ChatMessage
>
msg
=
q
->
createMessage
(
);
shared_ptr
<
ChatMessage
>
msg
=
createChatMessage
(
ChatMessage
::
Direction
::
Outgoing
);
Content
*
content
=
new
Content
();
content
->
setContentType
(
ContentType
::
ImIsComposing
);
content
->
setBody
(
payload
);
...
...
@@ -164,8 +164,8 @@ void ChatRoomPrivate::sendIsComposingNotification () {
// -----------------------------------------------------------------------------
shared_ptr
<
ChatMessage
>
ChatRoomPrivate
::
createChatMessage
(
ChatMessage
::
Direction
direction
)
{
// TODO: Create me.
return
nullptr
;
L_Q
();
return
shared_ptr
<
ChatMessage
>
(
new
ChatMessage
(
q
->
getSharedFromThis
(),
direction
))
;
}
// -----------------------------------------------------------------------------
...
...
src/core/core-chat-room.cpp
View file @
f117ff95
...
...
@@ -50,7 +50,9 @@ static inline ChatRoomId resolveWorkaroundClientGroupChatRoomId (
SimpleAddress
peerAddress
=
chatRoomId
.
getPeerAddress
();
peerAddress
.
setDomain
(
Address
(
uri
).
getDomain
());
return
ChatRoomId
(
peerAddress
,
chatRoomId
.
getLocalAddress
());
SimpleAddress
localAddress
=
chatRoomId
.
getLocalAddress
();
localAddress
.
setDomain
(
Address
(
uri
).
getDomain
());
return
ChatRoomId
(
peerAddress
,
localAddress
);
}
// TODO: Remove me later.
...
...
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