Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
21555417
Commit
21555417
authored
Dec 27, 2017
by
Ghislain MARY
Browse files
Handle callbacks in ProxyChatRoom.
parent
47943bf8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
106 additions
and
46 deletions
+106
-46
coreapi/chat.c
coreapi/chat.c
+2
-18
coreapi/linphonecore.c
coreapi/linphonecore.c
+4
-11
src/chat/chat-message/chat-message.cpp
src/chat/chat-message/chat-message.cpp
+1
-14
src/chat/chat-room/basic-to-client-group-chat-room.cpp
src/chat/chat-room/basic-to-client-group-chat-room.cpp
+1
-0
src/chat/chat-room/proxy-chat-room-p.h
src/chat/chat-room/proxy-chat-room-p.h
+4
-0
src/chat/chat-room/proxy-chat-room.cpp
src/chat/chat-room/proxy-chat-room.cpp
+92
-0
tester/group_chat_tester.c
tester/group_chat_tester.c
+1
-1
tester/rcfiles/marie_rc
tester/rcfiles/marie_rc
+1
-2
No files found.
coreapi/chat.c
View file @
21555417
...
...
@@ -132,24 +132,9 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op,
localAddress
=
op
->
get_to
();
}
// TODO: remove when using signals
LinphoneChatRoom
*
cr
=
L_GET_C_BACK_PTR
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
LinphonePrivate
::
ChatRoomId
(
LinphonePrivate
::
IdentityAddress
(
peerAddress
),
LinphonePrivate
::
IdentityAddress
(
localAddress
)
))
shared_ptr
<
LinphonePrivate
::
AbstractChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
LinphonePrivate
::
ChatRoomId
(
LinphonePrivate
::
IdentityAddress
(
peerAddress
),
LinphonePrivate
::
IdentityAddress
(
localAddress
))
);
if
(
!
cr
)
return
LinphoneReasonNone
;
shared_ptr
<
LinphonePrivate
::
AbstractChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
);
shared_ptr
<
LinphonePrivate
::
AbstractChatRoom
>
acr
;
if
(
chatRoom
->
getCapabilities
()
&
LinphonePrivate
::
ChatRoom
::
Capabilities
::
Proxy
)
acr
=
static_pointer_cast
<
LinphonePrivate
::
ClientGroupToBasicChatRoom
>
(
chatRoom
)
->
getProxiedChatRoom
();
else
acr
=
chatRoom
;
L_SET_CPP_PTR_FROM_C_OBJECT
(
cr
,
acr
);
if
(
chatRoom
)
reason
=
L_GET_PRIVATE
(
chatRoom
)
->
onSipMessageReceived
(
op
,
sal_msg
);
else
{
...
...
@@ -160,7 +145,6 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op,
reason
=
L_GET_PRIVATE_FROM_C_OBJECT
(
cr
)
->
onSipMessageReceived
(
op
,
sal_msg
);
linphone_address_unref
(
addr
);
}
L_SET_CPP_PTR_FROM_C_OBJECT
(
cr
,
chatRoom
);
return
reason
;
}
...
...
coreapi/linphonecore.c
View file @
21555417
...
...
@@ -2136,14 +2136,10 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
const
LinphoneAddress
*
resource
=
linphone_event_get_resource
(
lev
);
const
LinphoneAddress
*
from
=
linphone_event_get_from
(
lev
);
// TODO: remove when using signals
LinphoneChatRoom
*
cr
=
L_GET_C_BACK_PTR
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
LinphonePrivate
::
ChatRoomId
(
IdentityAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
resource
)),
IdentityAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
from
))
))
);
shared_ptr
<
AbstractChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
);
shared_ptr
<
AbstractChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
LinphonePrivate
::
ChatRoomId
(
IdentityAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
resource
)),
IdentityAddress
(
*
L_GET_CPP_PTR_FROM_C_OBJECT
(
from
))
));
if
(
chatRoom
)
{
shared_ptr
<
ClientGroupChatRoom
>
cgcr
;
...
...
@@ -2153,7 +2149,6 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
else
cgcr
=
static_pointer_cast
<
ClientGroupChatRoom
>
(
chatRoom
);
L_SET_CPP_PTR_FROM_C_OBJECT
(
cr
,
cgcr
);
if
(
linphone_content_is_multipart
(
body
))
{
// TODO : migrate to c++ 'Content'.
int
i
=
0
;
...
...
@@ -2164,8 +2159,6 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
}
}
else
L_GET_PRIVATE
(
cgcr
)
->
notifyReceived
(
linphone_content_get_string_buffer
(
body
));
L_SET_CPP_PTR_FROM_C_OBJECT
(
cr
,
chatRoom
);
}
}
}
...
...
src/chat/chat-message/chat-message.cpp
View file @
21555417
...
...
@@ -858,20 +858,7 @@ void ChatMessage::send () {
return
;
}
// TODO: remove when using signals
LinphoneChatRoom
*
cr
=
L_GET_C_BACK_PTR
(
getCore
()
->
findChatRoom
(
getChatRoom
()
->
getChatRoomId
()));
shared_ptr
<
LinphonePrivate
::
AbstractChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
);
shared_ptr
<
LinphonePrivate
::
AbstractChatRoom
>
acr
;
if
(
chatRoom
->
getCapabilities
()
&
LinphonePrivate
::
ChatRoom
::
Capabilities
::
Proxy
)
acr
=
static_pointer_cast
<
LinphonePrivate
::
ClientGroupToBasicChatRoom
>
(
chatRoom
)
->
getProxiedChatRoom
();
else
acr
=
chatRoom
;
L_SET_CPP_PTR_FROM_C_OBJECT
(
cr
,
acr
);
acr
->
getPrivate
()
->
sendChatMessage
(
getSharedFromThis
());
L_SET_CPP_PTR_FROM_C_OBJECT
(
cr
,
chatRoom
);
getChatRoom
()
->
getPrivate
()
->
sendChatMessage
(
getSharedFromThis
());
}
void
ChatMessage
::
sendDeliveryNotification
(
LinphoneReason
reason
)
{
...
...
src/chat/chat-room/basic-to-client-group-chat-room.cpp
View file @
21555417
...
...
@@ -93,6 +93,7 @@ BasicToClientGroupChatRoom::BasicToClientGroupChatRoom (const shared_ptr<ChatRoo
BasicToClientGroupChatRoom
::
CapabilitiesMask
BasicToClientGroupChatRoom
::
getCapabilities
()
const
{
L_D
();
CapabilitiesMask
capabilities
=
d
->
chatRoom
->
getCapabilities
();
capabilities
.
set
(
Capabilities
::
Proxy
);
if
(
capabilities
.
isSet
(
Capabilities
::
Basic
))
capabilities
.
set
(
Capabilities
::
Migratable
);
return
capabilities
;
...
...
src/chat/chat-room/proxy-chat-room-p.h
View file @
21555417
...
...
@@ -64,7 +64,11 @@ public:
chatRoom
->
getPrivate
()
->
onChatMessageReceived
(
chatMessage
);
}
void
setupCallbacks
();
std
::
shared_ptr
<
AbstractChatRoom
>
chatRoom
;
L_DECLARE_PUBLIC
(
ProxyChatRoom
);
};
LINPHONE_END_NAMESPACE
...
...
src/chat/chat-room/proxy-chat-room.cpp
View file @
21555417
...
...
@@ -20,6 +20,7 @@
#include "basic-to-client-group-chat-room.h"
#include "chat-room.h"
#include "proxy-chat-room-p.h"
#include "c-wrapper/c-wrapper.h"
// =============================================================================
...
...
@@ -27,12 +28,103 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
#define PROXY_CALLBACK(callback, ...) \
LinphoneChatRoomCbs *proxiedCbs = linphone_chat_room_get_callbacks(cr); \
ProxyChatRoom *pcr = static_cast<ProxyChatRoom *>(linphone_chat_room_cbs_get_user_data(proxiedCbs)); \
LinphoneChatRoom *lcr = L_GET_C_BACK_PTR(pcr->getSharedFromThis()); \
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(lcr); \
if (linphone_chat_room_cbs_get_ ## callback(cbs)) \
linphone_chat_room_cbs_get_ ## callback(cbs)(__VA_ARGS__)
static
void
chatMessageReceived
(
LinphoneChatRoom
*
cr
,
const
LinphoneEventLog
*
event_log
)
{
PROXY_CALLBACK
(
chat_message_received
,
cr
,
event_log
);
}
static
void
chatMessageSent
(
LinphoneChatRoom
*
cr
,
const
LinphoneEventLog
*
event_log
)
{
PROXY_CALLBACK
(
chat_message_sent
,
cr
,
event_log
);
}
static
void
conferenceAddressGeneration
(
LinphoneChatRoom
*
cr
)
{
PROXY_CALLBACK
(
conference_address_generation
,
cr
);
}
static
void
isComposingReceived
(
LinphoneChatRoom
*
cr
,
const
LinphoneAddress
*
remoteAddr
,
bool_t
isComposing
)
{
PROXY_CALLBACK
(
is_composing_received
,
cr
,
remoteAddr
,
isComposing
);
}
static
void
messageReceived
(
LinphoneChatRoom
*
cr
,
LinphoneChatMessage
*
msg
)
{
PROXY_CALLBACK
(
message_received
,
cr
,
msg
);
}
static
void
participantAdded
(
LinphoneChatRoom
*
cr
,
const
LinphoneEventLog
*
event_log
)
{
PROXY_CALLBACK
(
participant_added
,
cr
,
event_log
);
}
static
void
participantAdminStatusChanged
(
LinphoneChatRoom
*
cr
,
const
LinphoneEventLog
*
event_log
)
{
PROXY_CALLBACK
(
participant_admin_status_changed
,
cr
,
event_log
);
}
static
void
participantDeviceAdded
(
LinphoneChatRoom
*
cr
,
const
LinphoneEventLog
*
event_log
)
{
PROXY_CALLBACK
(
participant_device_added
,
cr
,
event_log
);
}
static
void
participantDeviceFetched
(
LinphoneChatRoom
*
cr
,
const
LinphoneAddress
*
participantAddr
)
{
PROXY_CALLBACK
(
participant_device_fetched
,
cr
,
participantAddr
);
}
static
void
participantDeviceRemoved
(
LinphoneChatRoom
*
cr
,
const
LinphoneEventLog
*
event_log
)
{
PROXY_CALLBACK
(
participant_device_removed
,
cr
,
event_log
);
}
static
void
participantRemoved
(
LinphoneChatRoom
*
cr
,
const
LinphoneEventLog
*
event_log
)
{
PROXY_CALLBACK
(
participant_removed
,
cr
,
event_log
);
}
static
void
participantsCapabilitiesChecked
(
LinphoneChatRoom
*
cr
,
const
LinphoneAddress
*
deviceAddr
,
const
bctbx_list_t
*
participantsAddr
)
{
PROXY_CALLBACK
(
participants_capabilities_checked
,
cr
,
deviceAddr
,
participantsAddr
);
}
static
void
stateChanged
(
LinphoneChatRoom
*
cr
,
LinphoneChatRoomState
newState
)
{
PROXY_CALLBACK
(
state_changed
,
cr
,
newState
);
}
static
void
subjectChanged
(
LinphoneChatRoom
*
cr
,
const
LinphoneEventLog
*
event_log
)
{
PROXY_CALLBACK
(
subject_changed
,
cr
,
event_log
);
}
static
void
undecryptableMessageReceived
(
LinphoneChatRoom
*
cr
,
LinphoneChatMessage
*
msg
)
{
PROXY_CALLBACK
(
undecryptable_message_received
,
cr
,
msg
);
}
void
ProxyChatRoomPrivate
::
setupCallbacks
()
{
L_Q
();
LinphoneChatRoom
*
lcr
=
L_GET_C_BACK_PTR
(
chatRoom
);
LinphoneChatRoomCbs
*
cbs
=
linphone_chat_room_get_callbacks
(
lcr
);
linphone_chat_room_cbs_set_user_data
(
cbs
,
q
);
linphone_chat_room_cbs_set_chat_message_received
(
cbs
,
chatMessageReceived
);
linphone_chat_room_cbs_set_chat_message_sent
(
cbs
,
chatMessageSent
);
linphone_chat_room_cbs_set_conference_address_generation
(
cbs
,
conferenceAddressGeneration
);
linphone_chat_room_cbs_set_is_composing_received
(
cbs
,
isComposingReceived
);
linphone_chat_room_cbs_set_message_received
(
cbs
,
messageReceived
);
linphone_chat_room_cbs_set_participant_added
(
cbs
,
participantAdded
);
linphone_chat_room_cbs_set_participant_admin_status_changed
(
cbs
,
participantAdminStatusChanged
);
linphone_chat_room_cbs_set_participant_device_added
(
cbs
,
participantDeviceAdded
);
linphone_chat_room_cbs_set_participant_device_fetched
(
cbs
,
participantDeviceFetched
);
linphone_chat_room_cbs_set_participant_device_removed
(
cbs
,
participantDeviceRemoved
);
linphone_chat_room_cbs_set_participant_removed
(
cbs
,
participantRemoved
);
linphone_chat_room_cbs_set_participants_capabilities_checked
(
cbs
,
participantsCapabilitiesChecked
);
linphone_chat_room_cbs_set_state_changed
(
cbs
,
stateChanged
);
linphone_chat_room_cbs_set_subject_changed
(
cbs
,
subjectChanged
);
linphone_chat_room_cbs_set_undecryptable_message_received
(
cbs
,
undecryptableMessageReceived
);
}
// -----------------------------------------------------------------------------
ProxyChatRoom
::
ProxyChatRoom
(
ProxyChatRoomPrivate
&
p
,
const
shared_ptr
<
ChatRoom
>
&
chatRoom
)
:
AbstractChatRoom
(
p
,
chatRoom
->
getCore
())
{
L_D
();
d
->
chatRoom
=
chatRoom
;
d
->
setupCallbacks
();
}
// -----------------------------------------------------------------------------
...
...
tester/group_chat_tester.c
View file @
21555417
...
...
@@ -1655,7 +1655,7 @@ static void group_chat_room_migrate_from_basic_chat_room (void) {
if
(
marieCr
)
{
initialMarieStats
=
marie
->
stat
;
initialPaulineStats
=
pauline
->
stat
;
BC_ASSERT_EQUAL
(
linphone_chat_room_get_capabilities
(
marieCr
),
LinphoneChatRoomCapabilitiesBasic
|
LinphoneChatRoomCapabilitiesProxy
,
int
,
"%d"
);
BC_ASSERT_EQUAL
(
linphone_chat_room_get_capabilities
(
marieCr
),
LinphoneChatRoomCapabilitiesBasic
|
LinphoneChatRoomCapabilitiesProxy
|
LinphoneChatRoomCapabilitiesMigratable
,
int
,
"%d"
);
msg
=
linphone_chat_room_create_message
(
marieCr
,
"Did you migrate?"
);
linphone_chat_message_send
(
msg
);
BC_ASSERT_TRUE
(
wait_for_list
(
coresList
,
&
marie
->
stat
.
number_of_LinphoneChatRoomStateCreationPending
,
initialMarieStats
.
number_of_LinphoneChatRoomStateCreationPending
+
1
,
10000
));
...
...
tester/rcfiles/marie_rc
View file @
21555417
...
...
@@ -4,7 +4,6 @@ sip_tcp_port=-1
sip_tls_port=-1
default_proxy=0
ping_with_options=0
composing_idle_timeout=1
store_ha1_passwd=0 #used for sipp
...
...
@@ -29,7 +28,7 @@ pol=accept
subscribe=0
[misc]
conference
-
factory
-
uri=sip:conference-factory@conf.example.org
conference
_
factory
_
uri=sip:conference-factory@conf.example.org
[rtp]
audio_rtp_port=18070-28000
...
...
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