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
47cf1d43
Commit
47cf1d43
authored
Dec 01, 2017
by
Ronan
Browse files
fix(c-chat-room): repair get history function
parent
eb3fbf68
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/c-wrapper/api/c-chat-room.cpp
View file @
47cf1d43
...
...
@@ -196,30 +196,24 @@ void linphone_chat_room_delete_history (LinphoneChatRoom *cr) {
}
bctbx_list_t
*
linphone_chat_room_get_history_range
(
LinphoneChatRoom
*
cr
,
int
startm
,
int
endm
)
{
return
L_GET_RESOLVED_C_LIST_FROM_CPP_LIST
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getHistoryRange
(
startm
,
endm
));
list
<
shared_ptr
<
LinphonePrivate
::
ChatMessage
>>
chatMessages
;
for
(
auto
&
event
:
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getHistoryRange
(
startm
,
endm
))
if
(
event
->
getType
()
==
LinphonePrivate
::
EventLog
::
Type
::
ConferenceChatMessage
)
chatMessages
.
push_back
(
static_pointer_cast
<
LinphonePrivate
::
ConferenceChatMessageEvent
>
(
event
)
->
getChatMessage
());
return
L_GET_RESOLVED_C_LIST_FROM_CPP_LIST
(
chatMessages
);
}
bctbx_list_t
*
linphone_chat_room_get_history
(
LinphoneChatRoom
*
cr
,
int
nb_message
)
{
return
L_GET_RESOLVED_C_LIST_FROM_CPP_LIST
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
get
H
istory
(
nb_message
)
)
;
return
linphone_chat_room_
get
_h
istory
_range
(
cr
,
0
,
nb_message
);
}
bctbx_list_t
*
linphone_chat_room_get_history_events
(
LinphoneChatRoom
*
cr
,
int
nb_events
)
{
return
L_GET_RESOLVED_C_LIST_FROM_CPP_LIST
(
L_GET_PRIVATE
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getCore
())
->
mainDb
->
getHistory
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getChatRoomId
(),
nb_events
)
);
return
L_GET_RESOLVED_C_LIST_FROM_CPP_LIST
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getHistory
(
nb_events
));
}
bctbx_list_t
*
linphone_chat_room_get_history_range_events
(
LinphoneChatRoom
*
cr
,
int
begin
,
int
end
)
{
return
L_GET_RESOLVED_C_LIST_FROM_CPP_LIST
(
L_GET_PRIVATE
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getCore
())
->
mainDb
->
getHistory
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getChatRoomId
(),
begin
,
end
)
);
return
L_GET_RESOLVED_C_LIST_FROM_CPP_LIST
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getHistoryRange
(
begin
,
end
));
}
LinphoneChatMessage
*
linphone_chat_room_get_last_message_in_history
(
LinphoneChatRoom
*
cr
)
{
...
...
src/chat/chat-room/chat-room.cpp
View file @
47cf1d43
...
...
@@ -406,17 +406,16 @@ shared_ptr<ChatMessage> ChatRoom::findMessageWithDirection (const string &messag
return
ret
;
}
list
<
shared_ptr
<
ChatMessage
>
>
ChatRoom
::
getHistory
(
int
n
bMessages
)
{
return
get
HistoryRange
(
0
,
nbMessages
-
1
);
list
<
shared_ptr
<
EventLog
>
>
ChatRoom
::
getHistory
(
int
n
Last
)
{
return
get
Core
()
->
getPrivate
()
->
mainDb
->
getHistory
(
getChatRoomId
(),
nLast
);
}
int
ChatRoom
::
getHistorySize
(
)
{
return
getCore
()
->
getPrivate
()
->
mainDb
->
get
ChatMessagesCount
(
getChatRoomId
());
list
<
shared_ptr
<
EventLog
>>
ChatRoom
::
getHistoryRange
(
int
begin
,
int
end
)
{
return
getCore
()
->
getPrivate
()
->
mainDb
->
get
HistoryRange
(
getChatRoomId
()
,
begin
,
end
);
}
list
<
shared_ptr
<
ChatMessage
>
>
ChatRoom
::
getHistoryRange
(
int
startm
,
int
endm
)
{
// TODO: history.
return
list
<
shared_ptr
<
ChatMessage
>>
();
int
ChatRoom
::
getHistorySize
()
{
return
getCore
()
->
getPrivate
()
->
mainDb
->
getChatMessagesCount
(
getChatRoomId
());
}
shared_ptr
<
ChatMessage
>
ChatRoom
::
getLastMessageInHistory
()
const
{
...
...
src/chat/chat-room/chat-room.h
View file @
47cf1d43
...
...
@@ -29,6 +29,7 @@
LINPHONE_BEGIN_NAMESPACE
class
ChatRoomPrivate
;
class
EventLog
;
class
LINPHONE_PUBLIC
ChatRoom
:
public
Object
,
public
CoreAccessor
,
public
ConferenceInterface
{
friend
class
ChatMessage
;
...
...
@@ -59,6 +60,10 @@ public:
virtual
CapabilitiesMask
getCapabilities
()
const
=
0
;
virtual
bool
hasBeenLeft
()
const
=
0
;
std
::
list
<
std
::
shared_ptr
<
EventLog
>>
getHistory
(
int
nLast
);
std
::
list
<
std
::
shared_ptr
<
EventLog
>>
getHistoryRange
(
int
begin
,
int
end
);
int
getHistorySize
();
std
::
shared_ptr
<
ChatMessage
>
getLastMessageInHistory
()
const
;
// TODO: Remove useless functions.
...
...
@@ -69,9 +74,6 @@ public:
void
deleteHistory
();
std
::
shared_ptr
<
ChatMessage
>
findMessage
(
const
std
::
string
&
messageId
);
std
::
shared_ptr
<
ChatMessage
>
findMessageWithDirection
(
const
std
::
string
&
messageId
,
ChatMessage
::
Direction
direction
);
std
::
list
<
std
::
shared_ptr
<
ChatMessage
>>
getHistory
(
int
nbMessages
);
int
getHistorySize
();
std
::
list
<
std
::
shared_ptr
<
ChatMessage
>>
getHistoryRange
(
int
startm
,
int
endm
);
int
getUnreadChatMessagesCount
();
bool
isRemoteComposing
()
const
;
std
::
list
<
Address
>
getComposingAddresses
()
const
;
...
...
src/db/main-db.cpp
View file @
47cf1d43
...
...
@@ -1566,14 +1566,14 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
}
string
query
=
"SELECT id, creation_time FROM event WHERE"
" id IN ("
" SELECT conference_event.event_id FROM conference_event, conference_chat_message_event"
" WHERE"
;
"
id IN ("
"
SELECT conference_event.event_id FROM conference_event, conference_chat_message_event"
"
WHERE"
;
if
(
chatRoomId
.
isValid
())
query
+=
" chat_room_id = :chatRoomId AND "
;
query
+=
" conference_event.event_id = conference_chat_message_event.event_id"
" AND direction = "
+
Utils
::
toString
(
static_cast
<
int
>
(
ChatMessage
::
Direction
::
Incoming
))
+
" AND state <> "
+
Utils
::
toString
(
static_cast
<
int
>
(
ChatMessage
::
State
::
Displayed
))
+
query
+=
"
chat_room_id = :chatRoomId AND "
;
query
+=
"
conference_event.event_id = conference_chat_message_event.event_id"
"
AND direction = "
+
Utils
::
toString
(
static_cast
<
int
>
(
ChatMessage
::
Direction
::
Incoming
))
+
"
AND state <> "
+
Utils
::
toString
(
static_cast
<
int
>
(
ChatMessage
::
State
::
Displayed
))
+
")"
;
DurationLogger
durationLogger
(
...
...
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