Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
8576147a
Commit
8576147a
authored
Feb 21, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(src/components/chat/ChatModel): supports terminated calls
parent
990dc04f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
35 deletions
+56
-35
ChatModel.cpp
linphone-desktop/src/components/chat/ChatModel.cpp
+55
-35
ChatModel.hpp
linphone-desktop/src/components/chat/ChatModel.hpp
+1
-0
No files found.
linphone-desktop/src/components/chat/ChatModel.cpp
View file @
8576147a
...
...
@@ -169,10 +169,12 @@ private:
// -----------------------------------------------------------------------------
ChatModel
::
ChatModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
m_core_handlers
=
CoreManager
::
getInstance
()
->
getHandlers
();
CoreManager
*
core
=
CoreManager
::
getInstance
();
m_core_handlers
=
core
->
getHandlers
();
m_message_handlers
=
make_shared
<
MessageHandlers
>
(
this
);
CoreManager
::
getInstance
()
->
getSipAddressesModel
()
->
connectToChatModel
(
this
);
core
->
getSipAddressesModel
()
->
connectToChatModel
(
this
);
QObject
::
connect
(
&
(
*
m_core_handlers
),
&
CoreHandlers
::
messageReceived
,
...
...
@@ -185,6 +187,14 @@ ChatModel::ChatModel (QObject *parent) : QAbstractListModel(parent) {
}
}
);
QObject
::
connect
(
&
(
*
m_core_handlers
),
&
CoreHandlers
::
callStateChanged
,
this
,
[
this
](
const
std
::
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
)
{
if
(
state
==
linphone
::
CallStateEnd
||
state
==
linphone
::
CallStateError
)
insertCall
(
call
->
getCallLog
());
}
);
}
ChatModel
::~
ChatModel
()
{
...
...
@@ -282,39 +292,8 @@ void ChatModel::setSipAddress (const QString &sip_address) {
}
// Get calls.
auto
insert_entry
=
[
this
](
const
ChatEntryData
&
pair
,
const
QList
<
ChatEntryData
>::
iterator
*
start
=
NULL
)
{
auto
it
=
lower_bound
(
start
?
*
start
:
m_entries
.
begin
(),
m_entries
.
end
(),
pair
,
[](
const
ChatEntryData
&
a
,
const
ChatEntryData
&
b
)
{
return
a
.
first
[
"timestamp"
]
<
b
.
first
[
"timestamp"
];
}
);
return
m_entries
.
insert
(
it
,
pair
);
};
for
(
auto
&
call_log
:
core
->
getCallHistoryForAddress
(
m_chat_room
->
getPeerAddress
()))
{
linphone
::
CallStatus
status
=
call_log
->
getStatus
();
// Ignore aborted calls.
if
(
status
==
linphone
::
CallStatusAborted
)
continue
;
// Add start call.
QVariantMap
start
;
fillCallStartEntry
(
start
,
call_log
);
auto
it
=
insert_entry
(
qMakePair
(
start
,
static_pointer_cast
<
void
>
(
call_log
)));
// Add end call. (if necessary)
if
(
status
==
linphone
::
CallStatusSuccess
)
{
QVariantMap
end
;
fillCallEndEntry
(
end
,
call_log
);
insert_entry
(
qMakePair
(
end
,
static_pointer_cast
<
void
>
(
call_log
)),
&
it
);
}
}
for
(
auto
&
call_log
:
core
->
getCallHistoryForAddress
(
m_chat_room
->
getPeerAddress
()))
insertCall
(
call_log
);
endResetModel
();
...
...
@@ -379,6 +358,7 @@ void ChatModel::resendMessage (int id) {
switch
(
map
[
"status"
].
toInt
())
{
case
MessageStatusFileTransferError
:
case
MessageStatusNotDelivered
:
{
// TODO: Do not duplicate me! Use a linphone core function in the future.
shared_ptr
<
linphone
::
ChatMessage
>
message
=
static_pointer_cast
<
linphone
::
ChatMessage
>
(
entry
.
second
);
shared_ptr
<
linphone
::
ChatMessage
>
message2
=
message
->
clone
();
...
...
@@ -544,6 +524,46 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
}
}
void
ChatModel
::
insertCall
(
const
shared_ptr
<
linphone
::
CallLog
>
&
call_log
)
{
auto
insert_entry
=
[
this
](
const
ChatEntryData
&
pair
,
const
QList
<
ChatEntryData
>::
iterator
*
start
=
NULL
)
{
auto
it
=
lower_bound
(
start
?
*
start
:
m_entries
.
begin
(),
m_entries
.
end
(),
pair
,
[](
const
ChatEntryData
&
a
,
const
ChatEntryData
&
b
)
{
return
a
.
first
[
"timestamp"
]
<
b
.
first
[
"timestamp"
];
}
);
int
row
=
static_cast
<
int
>
(
distance
(
m_entries
.
begin
(),
it
));
beginInsertRows
(
QModelIndex
(),
row
,
row
);
it
=
m_entries
.
insert
(
it
,
pair
);
endInsertRows
();
return
it
;
};
linphone
::
CallStatus
status
=
call_log
->
getStatus
();
// Ignore aborted calls.
if
(
status
==
linphone
::
CallStatusAborted
)
return
;
// Add start call.
QVariantMap
start
;
fillCallStartEntry
(
start
,
call_log
);
auto
it
=
insert_entry
(
qMakePair
(
start
,
static_pointer_cast
<
void
>
(
call_log
)));
// Add end call. (if necessary)
if
(
status
==
linphone
::
CallStatusSuccess
)
{
QVariantMap
end
;
fillCallEndEntry
(
end
,
call_log
);
insert_entry
(
qMakePair
(
end
,
static_pointer_cast
<
void
>
(
call_log
)),
&
it
);
}
}
void
ChatModel
::
insertMessageAtEnd
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
int
row
=
m_entries
.
count
();
...
...
linphone-desktop/src/components/chat/ChatModel.hpp
View file @
8576147a
...
...
@@ -117,6 +117,7 @@ private:
void
removeEntry
(
ChatEntryData
&
pair
);
void
insertCall
(
const
std
::
shared_ptr
<
linphone
::
CallLog
>
&
call_log
);
void
insertMessageAtEnd
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
void
resetMessagesCount
();
...
...
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