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
779646a3
Commit
779646a3
authored
Oct 03, 2017
by
Ronan
Browse files
feat(ChatMessage): use L_DECLARE_ENUM for state
parent
c4121b43
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
23 deletions
+47
-23
include/CMakeLists.txt
include/CMakeLists.txt
+1
-0
include/linphone/enums/chat-message-enums.h
include/linphone/enums/chat-message-enums.h
+34
-0
src/chat/chat-message.cpp
src/chat/chat-message.cpp
+10
-10
src/chat/chat-message.h
src/chat/chat-message.h
+2
-13
No files found.
include/CMakeLists.txt
View file @
779646a3
...
...
@@ -90,6 +90,7 @@ set(C_API_HEADER_FILES
)
set
(
ENUMS_HEADER_FILES
chat-message-enums.h
chat-room-enums.h
event-log-enums.h
)
...
...
include/linphone/enums/chat-message-enums.h
0 → 100644
View file @
779646a3
/*
* chat-room-enums.h
* Copyright (C) 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CHAT_MESSAGE_ENUMS_H_
#define _CHAT_MESSAGE_ENUMS_H_
// =============================================================================
#define L_ENUM_VALUES_CHAT_MESSAGE_STATE(F) \
F(Idle) \
F(InProgress) \
F(Delivered) \
F(NotDelivered) \
F(FileTransferError) \
F(FileTransferDone) \
F(DeliveredToUser) \
F(Displayed)
#endif // ifndef _CHAT_MESSAGE_ENUMS_H_
src/chat/chat-message.cpp
View file @
779646a3
...
...
@@ -1221,9 +1221,9 @@ bool ChatMessage::isRead() const {
L_D
();
LinphoneCore
*
lc
=
d
->
chatRoom
->
getCore
();
LinphoneImNotifPolicy
*
policy
=
linphone_core_get_im_notif_policy
(
lc
);
if
(
linphone_im_notif_policy_get_recv_imdn_displayed
(
policy
)
&&
d
->
state
==
Displayed
)
return
true
;
if
(
linphone_im_notif_policy_get_recv_imdn_delivered
(
policy
)
&&
(
d
->
state
==
DeliveredToUser
||
d
->
state
==
Displayed
))
return
true
;
return
d
->
state
==
Delivered
||
d
->
state
==
Displayed
||
d
->
state
==
DeliveredToUser
;
if
(
linphone_im_notif_policy_get_recv_imdn_displayed
(
policy
)
&&
d
->
state
==
State
::
Displayed
)
return
true
;
if
(
linphone_im_notif_policy_get_recv_imdn_delivered
(
policy
)
&&
(
d
->
state
==
State
::
DeliveredToUser
||
d
->
state
==
State
::
Displayed
))
return
true
;
return
d
->
state
==
State
::
Delivered
||
d
->
state
==
State
::
Displayed
||
d
->
state
==
State
::
DeliveredToUser
;
}
const
string
&
ChatMessage
::
getAppdata
()
const
{
...
...
@@ -1354,14 +1354,14 @@ void ChatMessage::updateState(State state) {
d
->
setState
(
state
);
linphone_chat_message_store_state
(
L_GET_C_BACK_PTR
(
this
));
if
(
state
==
Delivered
||
state
==
NotDelivered
)
if
(
state
==
State
::
Delivered
||
state
==
State
::
NotDelivered
)
d
->
chatRoom
->
getPrivate
()
->
moveTransientMessageToWeakMessages
(
getSharedFromThis
());
}
void
ChatMessage
::
reSend
()
{
L_D
();
if
(
d
->
state
!=
NotDelivered
)
{
if
(
d
->
state
!=
State
::
NotDelivered
)
{
lWarning
()
<<
"Cannot resend chat message in state "
<<
linphone_chat_message_state_to_string
((
LinphoneChatMessageState
)
d
->
state
);
return
;
}
...
...
@@ -1402,7 +1402,7 @@ int ChatMessage::uploadFile() {
int
err
=
d
->
startHttpTransfer
(
linphone_core_get_file_transfer_server
(
d
->
chatRoom
->
getCore
()),
"POST"
,
&
cbs
);
if
(
err
==
-
1
)
{
d
->
setState
(
NotDelivered
);
d
->
setState
(
State
::
NotDelivered
);
}
return
err
;
}
...
...
@@ -1424,15 +1424,15 @@ int ChatMessage::downloadFile() {
if
(
err
==
-
1
)
return
-
1
;
// start the download, status is In Progress
d
->
setState
(
InProgress
);
d
->
setState
(
State
::
InProgress
);
return
0
;
}
void
ChatMessage
::
cancelFileTransfer
()
{
L_D
();
if
(
d
->
httpRequest
)
{
if
(
d
->
state
==
InProgress
)
{
d
->
setState
(
NotDelivered
);
if
(
d
->
state
==
State
::
InProgress
)
{
d
->
setState
(
State
::
NotDelivered
);
}
if
(
!
belle_http_request_is_cancelled
(
d
->
httpRequest
))
{
if
(
d
->
chatRoom
)
{
...
...
@@ -1467,7 +1467,7 @@ int ChatMessage::putCharacter(uint32_t character) {
if
(
lc
&&
lp_config_get_int
(
lc
->
config
,
"misc"
,
"store_rtt_messages"
,
1
)
==
1
)
{
lDebug
()
<<
"New line sent, forge a message with content "
<<
d
->
rttMessage
.
c_str
();
d
->
setTime
(
ms_time
(
0
));
d
->
state
=
Displayed
;
d
->
state
=
State
::
Displayed
;
d
->
direction
=
Outgoing
;
setFromAddress
(
LinphonePrivate
::
Address
(
linphone_address_as_string
(
linphone_address_new
(
linphone_core_get_identity
(
lc
)))));
linphone_chat_message_store
(
L_GET_C_BACK_PTR
(
this
));
...
...
src/chat/chat-message.h
View file @
779646a3
...
...
@@ -20,11 +20,9 @@
#define _CHAT_MESSAGE_H_
#include <list>
#include <memory>
#include "enums.h"
#include "linphone/api/c-types.h"
#include "linphone/
api/c-
chat-message.h"
#include "linphone/
enums/
chat-message
-enums
.h"
#include "object/object.h"
...
...
@@ -52,16 +50,7 @@ public:
Outgoing
};
enum
State
{
Idle
,
InProgress
,
Delivered
,
NotDelivered
,
FileTransferError
,
FileTransferDone
,
DeliveredToUser
,
Displayed
};
L_DECLARE_ENUM
(
State
,
L_ENUM_VALUES_CHAT_MESSAGE_STATE
);
ChatMessage
(
const
std
::
shared_ptr
<
ChatRoom
>
&
room
);
virtual
~
ChatMessage
()
=
default
;
...
...
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