Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
liblinphone
Commits
9258c5f1
Commit
9258c5f1
authored
Dec 12, 2017
by
Ronan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ChatRoom): provide an abstract chat room for chat room migration proxy
parent
91196256
Changes
38
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
415 additions
and
280 deletions
+415
-280
coreapi/callbacks.c
coreapi/callbacks.c
+2
-2
coreapi/chat.c
coreapi/chat.c
+3
-3
coreapi/linphonecore.c
coreapi/linphonecore.c
+2
-2
coreapi/private_functions.h
coreapi/private_functions.h
+0
-1
include/linphone/api/c-chat-room.h
include/linphone/api/c-chat-room.h
+0
-13
src/CMakeLists.txt
src/CMakeLists.txt
+5
-0
src/c-wrapper/api/c-chat-room.cpp
src/c-wrapper/api/c-chat-room.cpp
+10
-23
src/c-wrapper/c-wrapper.h
src/c-wrapper/c-wrapper.h
+7
-5
src/chat/chat-message/chat-message-p.h
src/chat/chat-message/chat-message-p.h
+1
-1
src/chat/chat-message/chat-message.cpp
src/chat/chat-message/chat-message.cpp
+16
-17
src/chat/chat-message/chat-message.h
src/chat/chat-message/chat-message.h
+3
-3
src/chat/chat-room/abstract-chat-room-p.h
src/chat/chat-room/abstract-chat-room-p.h
+54
-0
src/chat/chat-room/abstract-chat-room.cpp
src/chat/chat-room/abstract-chat-room.cpp
+35
-0
src/chat/chat-room/abstract-chat-room.h
src/chat/chat-room/abstract-chat-room.h
+98
-0
src/chat/chat-room/basic-chat-room-p.h
src/chat/chat-room/basic-chat-room-p.h
+0
-2
src/chat/chat-room/basic-chat-room.cpp
src/chat/chat-room/basic-chat-room.cpp
+0
-4
src/chat/chat-room/basic-to-client-group-chat-room.cpp
src/chat/chat-room/basic-to-client-group-chat-room.cpp
+0
-0
src/chat/chat-room/basic-to-client-group-chat-room.h
src/chat/chat-room/basic-to-client-group-chat-room.h
+0
-0
src/chat/chat-room/chat-room-p.h
src/chat/chat-room/chat-room-p.h
+22
-21
src/chat/chat-room/chat-room.cpp
src/chat/chat-room/chat-room.cpp
+50
-52
src/chat/chat-room/chat-room.h
src/chat/chat-room/chat-room.h
+28
-39
src/chat/chat-room/client-group-chat-room-p.h
src/chat/chat-room/client-group-chat-room-p.h
+0
-2
src/chat/chat-room/client-group-chat-room.cpp
src/chat/chat-room/client-group-chat-room.cpp
+0
-4
src/chat/chat-room/real-time-text-chat-room-p.h
src/chat/chat-room/real-time-text-chat-room-p.h
+1
-1
src/chat/chat-room/real-time-text-chat-room.cpp
src/chat/chat-room/real-time-text-chat-room.cpp
+4
-4
src/chat/chat-room/server-group-chat-room-p.h
src/chat/chat-room/server-group-chat-room-p.h
+1
-3
src/chat/chat-room/server-group-chat-room-stub.cpp
src/chat/chat-room/server-group-chat-room-stub.cpp
+1
-5
src/chat/modifier/encryption-chat-message-modifier.cpp
src/chat/modifier/encryption-chat-message-modifier.cpp
+3
-3
src/chat/notification/imdn.cpp
src/chat/notification/imdn.cpp
+1
-1
src/core/core-chat-room.cpp
src/core/core-chat-room.cpp
+25
-27
src/core/core-p.h
src/core/core-p.h
+5
-5
src/core/core.h
src/core/core.h
+14
-11
src/db/main-db-p.h
src/db/main-db-p.h
+1
-1
src/db/main-db.cpp
src/db/main-db.cpp
+16
-17
src/db/main-db.h
src/db/main-db.h
+3
-3
tester/cpim-tester.cpp
tester/cpim-tester.cpp
+2
-2
tester/multipart-tester.cpp
tester/multipart-tester.cpp
+2
-2
tools/python/apixml2python.py
tools/python/apixml2python.py
+0
-1
No files found.
coreapi/callbacks.c
View file @
9258c5f1
...
...
@@ -87,7 +87,7 @@ static void call_received(SalCallOp *h) {
linphone_address_unref
(
fromAddr
);
return
;
}
else
if
(
sal_address_has_param
(
h
->
get_remote_contact_address
(),
"text"
))
{
shared_ptr
<
ChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
shared_ptr
<
Abstract
ChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
ChatRoomId
(
IdentityAddress
(
h
->
get_to
()),
IdentityAddress
(
h
->
get_to
()))
);
if
(
chatRoom
)
{
...
...
@@ -681,7 +681,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
if
(
addr
.
hasUriParam
(
"method"
)
&&
(
addr
.
getUriParamValue
(
"method"
)
==
"BYE"
))
{
if
(
linphone_core_conference_server_enabled
(
lc
))
{
// Removal of a participant at the server side
shared_ptr
<
ChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
shared_ptr
<
Abstract
ChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
ChatRoomId
(
IdentityAddress
(
op
->
get_to
()),
IdentityAddress
(
op
->
get_to
()))
);
if
(
chatRoom
)
{
...
...
coreapi/chat.c
View file @
9258c5f1
...
...
@@ -137,18 +137,18 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op,
localAddress
=
op
->
get_to
();
}
shared_ptr
<
LinphonePrivate
::
ChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
shared_ptr
<
LinphonePrivate
::
Abstract
ChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
LinphonePrivate
::
ChatRoomId
(
LinphonePrivate
::
IdentityAddress
(
peerAddress
),
LinphonePrivate
::
IdentityAddress
(
localAddress
))
);
if
(
chatRoom
)
reason
=
L_GET_PRIVATE
(
chatRoom
)
->
m
essageReceived
(
op
,
sal_msg
);
reason
=
L_GET_PRIVATE
(
chatRoom
)
->
onSipM
essageReceived
(
op
,
sal_msg
);
else
{
LinphoneAddress
*
addr
=
linphone_address_new
(
sal_msg
->
from
);
linphone_address_clean
(
addr
);
LinphoneChatRoom
*
cr
=
linphone_core_get_chat_room
(
lc
,
addr
);
if
(
cr
)
reason
=
L_GET_PRIVATE_FROM_C_OBJECT
(
cr
)
->
m
essageReceived
(
op
,
sal_msg
);
reason
=
L_GET_PRIVATE_FROM_C_OBJECT
(
cr
)
->
onSipM
essageReceived
(
op
,
sal_msg
);
linphone_address_unref
(
addr
);
}
return
reason
;
...
...
coreapi/linphonecore.c
View file @
9258c5f1
...
...
@@ -2134,7 +2134,7 @@ 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
);
shared_ptr
<
ChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
LinphonePrivate
::
ChatRoomId
(
shared_ptr
<
Abstract
ChatRoom
>
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
))
));
...
...
@@ -2164,7 +2164,7 @@ static void _linphone_core_conference_subscription_state_changed(LinphoneCore *l
state
==
LinphoneSubscriptionIncomingReceived
)
{
const
LinphoneAddress
*
resource
=
linphone_event_get_resource
(
lev
);
shared_ptr
<
ChatRoom
>
chatRoom
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
lc
)
->
findChatRoom
(
LinphonePrivate
::
ChatRoomId
(
shared_ptr
<
Abstract
ChatRoom
>
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
(
resource
))
));
...
...
coreapi/private_functions.h
View file @
9258c5f1
...
...
@@ -274,7 +274,6 @@ void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj);
/*chat*/
LinphoneChatRoom
*
_linphone_client_group_chat_room_new
(
LinphoneCore
*
core
,
const
char
*
uri
,
const
char
*
subject
);
LinphoneChatRoom
*
_linphone_server_group_chat_room_new
(
LinphoneCore
*
core
,
LinphonePrivate
::
SalCallOp
*
op
);
void
linphone_chat_room_release
(
LinphoneChatRoom
*
cr
);
void
linphone_chat_room_set_call
(
LinphoneChatRoom
*
cr
,
LinphoneCall
*
call
);
LinphoneChatRoomCbs
*
linphone_chat_room_cbs_new
(
void
);
/**/
...
...
include/linphone/api/c-chat-room.h
View file @
9258c5f1
...
...
@@ -116,19 +116,6 @@ LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_room_get_local_address(Linp
*/
LINPHONE_PUBLIC
LINPHONE_DEPRECATED
void
linphone_chat_room_send_message
(
LinphoneChatRoom
*
cr
,
const
char
*
msg
);
/**
* Send a message to peer member of this chat room.
* @param cr #LinphoneChatRoom object
* @param msg #LinphoneChatMessage message to be sent
* @param status_cb LinphoneChatMessageStateChangeCb status callback invoked when message is delivered or could not be delivered. May be NULL
* @param ud user data for the status cb.
* @deprecated Use linphone_chat_message_send() instead.
* @note The LinphoneChatMessage must not be destroyed until the the callback is called.
* The LinphoneChatMessage reference is transfered to the function and thus doesn't need to be unref'd by the application.
* @donotwrap
*/
LINPHONE_PUBLIC
LINPHONE_DEPRECATED
void
linphone_chat_room_send_message2
(
LinphoneChatRoom
*
cr
,
LinphoneChatMessage
*
msg
,
LinphoneChatMessageStateChangedCb
status_cb
,
void
*
ud
);
/**
* Send a message to peer member of this chat room.
* @param[in] cr LinphoneChatRoom object
...
...
src/CMakeLists.txt
View file @
9258c5f1
...
...
@@ -36,8 +36,11 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
call/remote-conference-call.h
chat/chat-message/chat-message-p.h
chat/chat-message/chat-message.h
chat/chat-room/abstract-chat-room-p.h
chat/chat-room/abstract-chat-room.h
chat/chat-room/basic-chat-room-p.h
chat/chat-room/basic-chat-room.h
chat/chat-room/basic-to-client-group-chat-room.h
chat/chat-room/chat-room-id.h
chat/chat-room/chat-room-p.h
chat/chat-room/chat-room.h
...
...
@@ -168,7 +171,9 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
call/local-conference-call.cpp
call/remote-conference-call.cpp
chat/chat-message/chat-message.cpp
chat/chat-room/abstract-chat-room.cpp
chat/chat-room/basic-chat-room.cpp
chat/chat-room/basic-to-client-group-chat-room.cpp
chat/chat-room/chat-room-id.cpp
chat/chat-room/chat-room.cpp
chat/chat-room/client-group-chat-room.cpp
...
...
src/c-wrapper/api/c-chat-room.cpp
View file @
9258c5f1
...
...
@@ -68,12 +68,8 @@ static void _linphone_chat_room_destructor (LinphoneChatRoom *cr) {
// Public functions.
// =============================================================================
void
linphone_chat_room_release
(
LinphoneChatRoom
*
cr
)
{
L_GET_PRIVATE_FROM_C_OBJECT
(
cr
)
->
release
();
}
void
linphone_chat_room_send_message
(
LinphoneChatRoom
*
cr
,
const
char
*
msg
)
{
L_GET_PRIVATE_FROM_C_OBJECT
(
cr
)
->
sendMessage
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
createMessage
(
msg
));
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
create
Chat
Message
(
msg
)
->
send
(
);
}
bool_t
linphone_chat_room_is_remote_composing
(
const
LinphoneChatRoom
*
cr
)
{
...
...
@@ -107,7 +103,7 @@ 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
)
->
createMessage
(
L_C_TO_STRING
(
message
));
shared_ptr
<
LinphonePrivate
::
ChatMessage
>
cppPtr
=
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
create
Chat
Message
(
L_C_TO_STRING
(
message
));
LinphoneChatMessage
*
object
=
L_INIT
(
ChatMessage
);
L_SET_CPP_PTR_FROM_C_OBJECT
(
object
,
cppPtr
);
return
object
;
...
...
@@ -130,24 +126,13 @@ LinphoneChatMessage *linphone_chat_room_create_message_2 (
return
msg
;
}
void
linphone_chat_room_send_message2
(
LinphoneChatRoom
*
cr
,
LinphoneChatMessage
*
msg
,
LinphoneChatMessageStateChangedCb
status_cb
,
void
*
ud
)
{
linphone_chat_message_set_message_state_changed_cb
(
msg
,
status_cb
);
linphone_chat_message_set_message_state_changed_cb_user_data
(
msg
,
ud
);
L_GET_PRIVATE_FROM_C_OBJECT
(
cr
)
->
sendMessage
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
msg
));
}
void
linphone_chat_room_send_chat_message_2
(
LinphoneChatRoom
*
cr
,
LinphoneChatMessage
*
msg
)
{
linphone_chat_message_ref
(
msg
);
L_GET_PRIVATE_FROM_C_OBJECT
(
cr
)
->
sendMessage
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
msg
));
L_GET_CPP_PTR_FROM_C_OBJECT
(
msg
)
->
send
(
);
}
void
linphone_chat_room_send_chat_message
(
LinphoneChatRoom
*
cr
,
LinphoneChatMessage
*
msg
)
{
L_GET_PRIVATE_FROM_C_OBJECT
(
cr
)
->
sendMessage
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
msg
));
L_GET_CPP_PTR_FROM_C_OBJECT
(
msg
)
->
send
(
);
}
void
linphone_chat_room_receive_chat_message
(
LinphoneChatRoom
*
cr
,
LinphoneChatMessage
*
msg
)
{
...
...
@@ -235,7 +220,7 @@ LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChat
}
LinphoneChatMessage
*
linphone_chat_room_find_message
(
LinphoneChatRoom
*
cr
,
const
char
*
message_id
)
{
return
L_GET_C_BACK_PTR
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
findMessage
(
message_id
));
return
L_GET_C_BACK_PTR
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
find
Chat
Message
(
message_id
));
}
LinphoneChatRoomCbs
*
linphone_chat_room_get_callbacks
(
const
LinphoneChatRoom
*
cr
)
{
...
...
@@ -323,8 +308,10 @@ void linphone_chat_room_set_subject (LinphoneChatRoom *cr, const char *subject)
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
setSubject
(
L_C_TO_STRING
(
subject
));
}
const
bctbx_list_t
*
linphone_chat_room_get_composing_addresses
(
LinphoneChatRoom
*
cr
)
{
return
L_GET_RESOLVED_C_LIST_FROM_CPP_LIST
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getComposingAddresses
());
const
bctbx_list_t
*
linphone_chat_room_get_composing_addresses
(
LinphoneChatRoom
*
cr
)
{
// FIXME
// return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getComposingAddresses());
return
nullptr
;
}
LinphoneChatMessage
*
linphone_chat_room_create_file_transfer_message
(
LinphoneChatRoom
*
cr
,
const
LinphoneContent
*
initial_content
)
{
...
...
@@ -389,7 +376,7 @@ LinphoneChatRoom *_linphone_client_group_chat_room_new (LinphoneCore *core, cons
L_SET_CPP_PTR_FROM_C_OBJECT
(
cr
,
make_shared
<
LinphonePrivate
::
ClientGroupChatRoom
>
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
core
),
L_C_TO_STRING
(
uri
),
me
,
L_C_TO_STRING
(
subject
))
);
L_GET_PRIVATE_FROM_C_OBJECT
(
cr
)
->
setState
(
LinphonePrivate
::
ChatRoom
::
State
::
Instantiated
);
L_GET_PRIVATE_FROM_C_OBJECT
(
cr
,
ChatRoom
)
->
setState
(
LinphonePrivate
::
ChatRoom
::
State
::
Instantiated
);
return
cr
;
}
...
...
src/c-wrapper/c-wrapper.h
View file @
9258c5f1
...
...
@@ -35,7 +35,7 @@
F(Address, Address) \
F(Call, Call) \
F(ChatMessage, ChatMessage) \
F(ChatRoom, ChatRoom) \
F(
Abstract
ChatRoom, ChatRoom) \
F(Core, Core) \
F(DialPlan, DialPlan) \
F(EventLog, EventLog) \
...
...
@@ -43,12 +43,14 @@
F(Participant, Participant)
#define L_REGISTER_SUBTYPES(F) \
F(AbstractChatRoom, BasicChatRoom) \
F(AbstractChatRoom, BasicToClientGroupChatRoom) \
F(AbstractChatRoom, ChatRoom) \
F(AbstractChatRoom, ClientGroupChatRoom) \
F(AbstractChatRoom, RealTimeTextChatRoom) \
F(AbstractChatRoom, ServerGroupChatRoom) \
F(Call, LocalConferenceCall) \
F(Call, RemoteConferenceCall) \
F(ChatRoom, BasicChatRoom) \
F(ChatRoom, ClientGroupChatRoom) \
F(ChatRoom, RealTimeTextChatRoom) \
F(ChatRoom, ServerGroupChatRoom) \
F(EventLog, ConferenceCallEvent) \
F(EventLog, ConferenceChatMessageEvent) \
F(EventLog, ConferenceEvent) \
...
...
src/chat/chat-message/chat-message-p.h
View file @
9258c5f1
...
...
@@ -156,7 +156,7 @@ public:
mutable
MainDbChatMessageKey
dbKey
;
private:
std
::
weak_ptr
<
ChatRoom
>
chatRoom
;
std
::
weak_ptr
<
Abstract
ChatRoom
>
chatRoom
;
ChatRoomId
chatRoomId
;
IdentityAddress
fromAddress
;
IdentityAddress
toAddress
;
...
...
src/chat/chat-message/chat-message.cpp
View file @
9258c5f1
...
...
@@ -67,7 +67,7 @@ void ChatMessagePrivate::setState (ChatMessage::State s, bool force) {
if
(
force
)
state
=
s
;
if
(
s
==
state
||
!
q
->
getChatRoom
()
)
if
(
s
==
state
)
return
;
if
(
...
...
@@ -316,7 +316,7 @@ void ChatMessagePrivate::loadFileTransferUrlFromBodyToContent() {
void
ChatMessagePrivate
::
sendImdn
(
Imdn
::
Type
imdnType
,
LinphoneReason
reason
)
{
L_Q
();
shared_ptr
<
ChatMessage
>
msg
=
q
->
getChatRoom
()
->
createMessage
();
shared_ptr
<
ChatMessage
>
msg
=
q
->
getChatRoom
()
->
create
Chat
Message
();
Content
*
content
=
new
Content
();
content
->
setContentType
(
"message/imdn+xml"
);
...
...
@@ -332,7 +332,7 @@ LinphoneReason ChatMessagePrivate::receive () {
LinphoneReason
reason
=
LinphoneReasonNone
;
shared_ptr
<
Core
>
core
=
q
->
getCore
();
shared_ptr
<
ChatRoom
>
chatRoom
=
q
->
getChatRoom
();
shared_ptr
<
Abstract
ChatRoom
>
chatRoom
=
q
->
getChatRoom
();
setState
(
ChatMessage
::
State
::
Delivered
);
...
...
@@ -357,8 +357,7 @@ LinphoneReason ChatMessagePrivate::receive () {
ChatMessageModifier
::
Result
result
=
ecmm
.
decode
(
q
->
getSharedFromThis
(),
errorCode
);
if
(
result
==
ChatMessageModifier
::
Result
::
Error
)
{
/* Unable to decrypt message */
if
(
chatRoom
)
chatRoom
->
getPrivate
()
->
notifyUndecryptableMessageReceived
(
q
->
getSharedFromThis
());
chatRoom
->
getPrivate
()
->
notifyUndecryptableMessageReceived
(
q
->
getSharedFromThis
());
reason
=
linphone_error_code_to_reason
(
errorCode
);
q
->
sendDeliveryNotification
(
reason
);
return
reason
;
...
...
@@ -416,7 +415,7 @@ LinphoneReason ChatMessagePrivate::receive () {
setDirection
(
ChatMessage
::
Direction
::
Outgoing
);
// Check if this is a duplicate message.
if
(
chatRoom
&&
chatRoom
->
findMessage
WithDirection
(
imdnId
,
direction
))
if
(
chatRoom
->
find
Chat
Message
(
imdnId
,
direction
))
return
core
->
getCCore
()
->
chat_deny_code
;
if
(
errorCode
>
0
)
{
...
...
@@ -632,9 +631,8 @@ void ChatMessagePrivate::store() {
// -----------------------------------------------------------------------------
ChatMessage
::
ChatMessage
(
const
shared_ptr
<
ChatRoom
>
&
chatRoom
,
ChatMessage
::
Direction
direction
)
:
ChatMessage
::
ChatMessage
(
const
shared_ptr
<
Abstract
ChatRoom
>
&
chatRoom
,
ChatMessage
::
Direction
direction
)
:
Object
(
*
new
ChatMessagePrivate
),
CoreAccessor
(
chatRoom
->
getCore
())
{
L_ASSERT
(
chatRoom
);
L_D
();
d
->
chatRoom
=
chatRoom
;
...
...
@@ -658,12 +656,17 @@ ChatMessage::~ChatMessage () {
d
->
salOp
->
release
();
}
shared_ptr
<
ChatRoom
>
ChatMessage
::
getChatRoom
()
const
{
shared_ptr
<
Abstract
ChatRoom
>
ChatMessage
::
getChatRoom
()
const
{
L_D
();
shared_ptr
<
ChatRoom
>
chatRoom
=
d
->
chatRoom
.
lock
();
if
(
!
chatRoom
)
shared_ptr
<
Abstract
ChatRoom
>
chatRoom
=
d
->
chatRoom
.
lock
();
if
(
!
chatRoom
)
{
chatRoom
=
getCore
()
->
getOrCreateBasicChatRoom
(
d
->
chatRoomId
);
if
(
!
chatRoom
)
{
lError
()
<<
"Unable to get valid chat room instance."
;
throw
logic_error
(
"Unable to get chat room of chat message."
);
}
}
return
chatRoom
;
}
...
...
@@ -813,9 +816,7 @@ void ChatMessage::send () {
return
;
}
shared_ptr
<
ChatRoom
>
chatRoom
=
getChatRoom
();
if
(
chatRoom
)
chatRoom
->
getPrivate
()
->
sendMessage
(
getSharedFromThis
());
getChatRoom
()
->
getPrivate
()
->
sendChatMessage
(
getSharedFromThis
());
}
void
ChatMessage
::
sendDeliveryNotification
(
LinphoneReason
reason
)
{
...
...
@@ -860,9 +861,7 @@ int ChatMessage::putCharacter (uint32_t character) {
static
const
uint32_t
crlf
=
0x0D0A
;
static
const
uint32_t
lf
=
0x0A
;
shared_ptr
<
ChatRoom
>
chatRoom
=
getChatRoom
();
if
(
!
chatRoom
)
return
-
1
;
shared_ptr
<
AbstractChatRoom
>
chatRoom
=
getChatRoom
();
shared_ptr
<
LinphonePrivate
::
RealTimeTextChatRoom
>
rttcr
=
static_pointer_cast
<
LinphonePrivate
::
RealTimeTextChatRoom
>
(
chatRoom
);
...
...
src/chat/chat-message/chat-message.h
View file @
9258c5f1
...
...
@@ -35,7 +35,7 @@
LINPHONE_BEGIN_NAMESPACE
class
ChatRoom
;
class
Abstract
ChatRoom
;
class
Content
;
class
FileTransferContent
;
class
ChatMessagePrivate
;
...
...
@@ -67,7 +67,7 @@ public:
void
setIsSecured
(
bool
isSecured
);
// ----- TODO: Remove me.
std
::
shared_ptr
<
ChatRoom
>
getChatRoom
()
const
;
std
::
shared_ptr
<
Abstract
ChatRoom
>
getChatRoom
()
const
;
void
send
();
...
...
@@ -102,7 +102,7 @@ public:
bool
downloadFile
(
FileTransferContent
&
content
);
private:
ChatMessage
(
const
std
::
shared_ptr
<
ChatRoom
>
&
chatRoom
,
ChatMessage
::
Direction
direction
);
ChatMessage
(
const
std
::
shared_ptr
<
Abstract
ChatRoom
>
&
chatRoom
,
ChatMessage
::
Direction
direction
);
L_DECLARE_PRIVATE
(
ChatMessage
);
L_DISABLE_COPY
(
ChatMessage
);
...
...
src/chat/chat-room/abstract-chat-room-p.h
0 → 100644
View file @
9258c5f1
/*
* abstract-chat-room-p.h
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _ABSTRACT_CHAT_ROOM_P_H_
#define _ABSTRACT_CHAT_ROOM_P_H_
#include "abstract-chat-room.h"
#include "object/object-p.h"
// =============================================================================
L_DECL_C_STRUCT_PREFIX_LESS
(
SalMessage
);
LINPHONE_BEGIN_NAMESPACE
class
SalOp
;
class
AbstractChatRoomPrivate
:
public
ObjectPrivate
{
public:
virtual
void
setCreationTime
(
time_t
creationTime
)
=
0
;
virtual
void
setLastUpdateTime
(
time_t
lastUpdateTime
)
=
0
;
virtual
void
setState
(
AbstractChatRoom
::
State
state
)
=
0
;
virtual
void
sendChatMessage
(
const
std
::
shared_ptr
<
ChatMessage
>
&
chatMessage
)
=
0
;
virtual
void
addTransientEvent
(
const
std
::
shared_ptr
<
EventLog
>
&
eventLog
)
=
0
;
virtual
void
removeTransientEvent
(
const
std
::
shared_ptr
<
EventLog
>
&
eventLog
)
=
0
;
virtual
void
notifyUndecryptableMessageReceived
(
const
std
::
shared_ptr
<
ChatMessage
>
&
chatMessage
)
=
0
;
virtual
void
onChatMessageReceived
(
const
std
::
shared_ptr
<
ChatMessage
>
&
chatMessage
)
=
0
;
virtual
LinphoneReason
onSipMessageReceived
(
SalOp
*
op
,
const
SalMessage
*
message
)
=
0
;
};
LINPHONE_END_NAMESPACE
#endif // ifndef _ABSTRACT_CHAT_ROOM_P_H_
src/chat/chat-room/abstract-chat-room.cpp
0 → 100644
View file @
9258c5f1
/*
* abstract-chat-room.cpp
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "abstract-chat-room-p.h"
// =============================================================================
using
namespace
std
;
LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
AbstractChatRoom
::
AbstractChatRoom
(
AbstractChatRoomPrivate
&
p
,
const
shared_ptr
<
Core
>
&
core
)
:
Object
(
p
),
CoreAccessor
(
core
)
{}
LINPHONE_END_NAMESPACE
src/chat/chat-room/abstract-chat-room.h
0 → 100644
View file @
9258c5f1
/*
* abstract-chat-room.h
* Copyright (C) 2010-2017 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _ABSTRACT_CHAT_ROOM_H_
#define _ABSTRACT_CHAT_ROOM_H_
#include "chat/chat-message/chat-message.h"
#include "conference/conference-interface.h"
#include "core/core-accessor.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class
AbstractChatRoomPrivate
;
class
ChatRoomId
;
class
EventLog
;
class
LINPHONE_PUBLIC
AbstractChatRoom
:
public
Object
,
public
CoreAccessor
,
public
ConferenceInterface
{
friend
class
ChatMessage
;
friend
class
ChatMessagePrivate
;
friend
class
CorePrivate
;
friend
class
MainDb
;
public:
L_DECLARE_ENUM
(
Capabilities
,
L_ENUM_VALUES_CHAT_ROOM_CAPABILITIES
);
L_DECLARE_ENUM
(
State
,
L_ENUM_VALUES_CHAT_ROOM_STATE
);
typedef
int
CapabilitiesMask
;
virtual
const
ChatRoomId
&
getChatRoomId
()
const
=
0
;
virtual
const
IdentityAddress
&
getPeerAddress
()
const
=
0
;
virtual
const
IdentityAddress
&
getLocalAddress
()
const
=
0
;
virtual
time_t
getCreationTime
()
const
=
0
;
virtual
time_t
getLastUpdateTime
()
const
=
0
;
virtual
CapabilitiesMask
getCapabilities
()
const
=
0
;
virtual
State
getState
()
const
=
0
;
virtual
bool
hasBeenLeft
()
const
=
0
;
virtual
std
::
list
<
std
::
shared_ptr
<
EventLog
>>
getHistory
(
int
nLast
)
const
=
0
;
virtual
std
::
list
<
std
::
shared_ptr
<
EventLog
>>
getHistoryRange
(
int
begin
,
int
end
)
const
=
0
;
virtual
int
getHistorySize
()
const
=
0
;
virtual
void
deleteHistory
()
=
0
;
virtual
std
::
shared_ptr
<
ChatMessage
>
getLastChatMessageInHistory
()
const
=
0
;
virtual
int
getChatMessageCount
()
const
=
0
;
virtual
int
getUnreadChatMessageCount
()
const
=
0
;
virtual
void
compose
()
=
0
;
virtual
bool
isRemoteComposing
()
const
=
0
;
virtual
std
::
list
<
IdentityAddress
>
getComposingAddresses
()
const
=
0
;
virtual
std
::
shared_ptr
<
ChatMessage
>
createChatMessage
()
=
0
;
virtual
std
::
shared_ptr
<
ChatMessage
>
createChatMessage
(
const
std
::
string
&
text
)
=
0
;
// TODO: Remove LinphoneContent by LinphonePrivate::Content.
virtual
std
::
shared_ptr
<
ChatMessage
>
createFileTransferMessage
(
const
LinphoneContent
*
initialContent
)
=
0
;
virtual
std
::
shared_ptr
<
ChatMessage
>
findChatMessage
(
const
std
::
string
&
messageId
)
const
=
0
;
virtual
std
::
shared_ptr
<
ChatMessage
>
findChatMessage
(
const
std
::
string
&
messageId
,
ChatMessage
::
Direction
direction
)
const
=
0
;
virtual
void
markAsRead
()
=
0
;
protected:
explicit
AbstractChatRoom
(
AbstractChatRoomPrivate
&
p
,
const
std
::
shared_ptr
<
Core
>
&
core
);
private:
L_DECLARE_PRIVATE
(
AbstractChatRoom
);
L_DISABLE_COPY
(
AbstractChatRoom
);
};
LINPHONE_END_NAMESPACE
#endif // ifndef _ABSTRACT_CHAT_ROOM_H_
src/chat/chat-room/basic-chat-room-p.h
View file @
9258c5f1
...
...
@@ -32,8 +32,6 @@ public:
BasicChatRoomPrivate
()
=
default
;
private:
void
onChatMessageReceived
(
const
std
::
shared_ptr
<
ChatMessage
>
&
chatMessage
)
override
;
std
::
string
subject
;
std
::
list
<
std
::
shared_ptr
<
Participant
>>
participants
;
...
...
src/chat/chat-room/basic-chat-room.cpp
View file @
9258c5f1
...
...
@@ -31,10 +31,6 @@ LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
void
BasicChatRoomPrivate
::
onChatMessageReceived
(
const
shared_ptr
<
ChatMessage
>
&
)
{}
// -----------------------------------------------------------------------------
BasicChatRoom
::
BasicChatRoom
(
const
shared_ptr
<
Core
>
&
core
,
const
ChatRoomId
&
chatRoomId
)
:
ChatRoom
(
*
new
BasicChatRoomPrivate
,
core
,
chatRoomId
)
{}
...
...
src/chat/chat-room/basic-to-client-group-chat-room.cpp
0 → 100644
View file @
9258c5f1
src/chat/chat-room/basic-to-client-group-chat-room.h
0 → 100644
View file @
9258c5f1
src/chat/chat-room/chat-room-p.h
View file @
9258c5f1
...
...
@@ -20,46 +20,50 @@
#ifndef _CHAT_ROOM_P_H_
#define _CHAT_ROOM_P_H_
#include <unordered_set>
#include "chat/notification/is-composing.h"
#include "abstract-chat-room-p.h"
#include "chat-room-id.h"
#include "chat-room.h"
#include "
object/object-p
.h"
#include "
chat/notification/is-composing
.h"
#include "event-log/event-log.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
// TODO: clean and order methods!
class
ChatRoomPrivate
:
public
ObjectPrivate
,
public
IsComposingListener
{
class
ChatRoomPrivate
:
public
AbstractChatRoomPrivate
,
public
IsComposingListener
{
public:
ChatRoomPrivate
()
=
default
;
void
setCreationTime
(
time_t
creationTime
)
override
{
this
->
creationTime
=
creationTime
;
}
void
setLastUpdateTime
(
time_t
lastUpdateTime
)
override
{
this
->
lastUpdateTime
=
lastUpdateTime
;
}