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
a20c32af
Commit
a20c32af
authored
Nov 21, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(TimelineModel): init with sqlite data
parent
9eb533b7
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
119 additions
and
30 deletions
+119
-30
CMakeLists.txt
tests/CMakeLists.txt
+1
-0
resources.qrc
tests/resources.qrc
+4
-0
Database.cpp
tests/src/app/Database.cpp
+6
-4
ContactsListModel.cpp
tests/src/components/contacts/ContactsListModel.cpp
+5
-3
ContactsListModel.hpp
tests/src/components/contacts/ContactsListModel.hpp
+1
-1
ContactsListProxyModel.cpp
tests/src/components/contacts/ContactsListProxyModel.cpp
+4
-2
CoreManager.cpp
tests/src/components/core/CoreManager.cpp
+1
-3
TimelineModel.cpp
tests/src/components/timeline/TimelineModel.cpp
+84
-16
TimelineModel.hpp
tests/src/components/timeline/TimelineModel.hpp
+5
-1
ConnectedCallsControl.qml
tests/ui/modules/Linphone/Call/ConnectedCallsControl.qml
+2
-0
IncomingCallControls.qml
tests/ui/modules/Linphone/Call/IncomingCallControls.qml
+2
-0
OutgoingCallControls.qml
tests/ui/modules/Linphone/Call/OutgoingCallControls.qml
+2
-0
PausedCallControls.qml
tests/ui/modules/Linphone/Call/PausedCallControls.qml
+2
-0
No files found.
tests/CMakeLists.txt
View file @
a20c32af
...
...
@@ -6,6 +6,7 @@ cmake_minimum_required(VERSION 3.1)
project
(
linphone
)
set
(
LINPHONE_EXEC linphone
)
set
(
CMAKE_CXX_STANDARD 11
)
# Use automatically moc from Qt5.
set
(
CMAKE_AUTOMOC ON
)
...
...
tests/resources.qrc
View file @
a20c32af
...
...
@@ -109,6 +109,10 @@
<file>
ui/modules/Common/View/ScrollableListView.qml
</file>
<file>
ui/modules/Linphone/Account/AccountStatus.qml
</file>
<file>
ui/modules/Linphone/Call/CallControls.qml
</file>
<file>
ui/modules/Linphone/Call/ConnectedCallsControl.qml
</file>
<file>
ui/modules/Linphone/Call/IncomingCallControls.qml
</file>
<file>
ui/modules/Linphone/Call/OutgoingCallControls.qml
</file>
<file>
ui/modules/Linphone/Call/PausedCallControls.qml
</file>
<file>
ui/modules/Linphone/Chat/Chat.qml
</file>
<file>
ui/modules/Linphone/Chat/Event.qml
</file>
<file>
ui/modules/Linphone/Chat/IncomingMessage.qml
</file>
...
...
tests/src/app/Database.cpp
View file @
a20c32af
...
...
@@ -16,6 +16,8 @@
#define DATABASE_PATH_CALL_HISTORY_LIST ".linphone-call-history.db"
#define DATABASE_PATH_MESSAGE_HISTORY_LIST ".linphone-history.db"
using
namespace
std
;
// ===================================================================
inline
bool
ensureDatabaseFilePathExists
(
const
QString
&
path
)
{
...
...
@@ -29,7 +31,7 @@ inline bool ensureDatabaseFilePathExists (const QString &path) {
return
file
.
exists
()
||
file
.
open
(
QIODevice
::
ReadWrite
);
}
inline
st
d
::
st
ring
getDatabaseFilePath
(
const
QString
&
filename
)
{
inline
string
getDatabaseFilePath
(
const
QString
&
filename
)
{
QString
path
(
DATABASES_PATH
+
"/"
);
path
+=
filename
;
return
ensureDatabaseFilePathExists
(
path
)
...
...
@@ -37,14 +39,14 @@ inline std::string getDatabaseFilePath (const QString &filename) {
:
""
;
}
st
d
::
st
ring
Database
::
getFriendsListPath
()
{
string
Database
::
getFriendsListPath
()
{
return
getDatabaseFilePath
(
DATABASE_PATH_FRIENDS_LIST
);
}
st
d
::
st
ring
Database
::
getCallHistoryPath
()
{
string
Database
::
getCallHistoryPath
()
{
return
getDatabaseFilePath
(
DATABASE_PATH_CALL_HISTORY_LIST
);
}
st
d
::
st
ring
Database
::
getMessageHistoryPath
()
{
string
Database
::
getMessageHistoryPath
()
{
return
getDatabaseFilePath
(
DATABASE_PATH_MESSAGE_HISTORY_LIST
);
}
tests/src/components/contacts/ContactsListModel.cpp
View file @
a20c32af
...
...
@@ -3,14 +3,16 @@
#include "ContactsListModel.hpp"
using
namespace
std
;
// ===================================================================
ContactsListModel
::
ContactsListModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
s
td
::
s
hared_ptr
<
linphone
::
Core
>
core
(
CoreManager
::
getInstance
()
->
getCore
());
shared_ptr
<
linphone
::
Core
>
core
(
CoreManager
::
getInstance
()
->
getCore
());
// Init contacts with linphone friends list.
for
(
auto
friend_
:
core
->
getFriendsLists
().
front
()
->
getFriends
())
{
m_list
<<
new
ContactModel
(
friend_
);
for
(
auto
&&
contact
:
core
->
getFriendsLists
().
front
()
->
getFriends
())
{
m_list
<<
new
ContactModel
(
contact
);
}
}
...
...
tests/src/components/contacts/ContactsListModel.hpp
View file @
a20c32af
...
...
@@ -6,7 +6,7 @@
#include "ContactModel.hpp"
// ===================================================================
#include <QtDebug>
class
ContactsListModel
:
public
QAbstractListModel
{
friend
class
ContactsListProxyModel
;
...
...
tests/src/components/contacts/ContactsListProxyModel.cpp
View file @
a20c32af
...
...
@@ -11,6 +11,8 @@
#define FACTOR_POS_3 0.70
#define FACTOR_POS_OTHER 0.60
using
namespace
std
;
// ===================================================================
ContactsListModel
*
ContactsListProxyModel
::
m_list
=
nullptr
;
...
...
@@ -117,10 +119,10 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel &contact)
float
weight
=
computeStringWeight
(
contact
.
getUsername
(),
USERNAME_WEIGHT
);
// Get all contact's addresses.
const
std
::
list
<
std
::
shared_ptr
<
linphone
::
Address
>
>
addresses
=
const
list
<
shared_ptr
<
linphone
::
Address
>
>
addresses
=
contact
.
m_linphone_friend
->
getAddresses
();
auto
it
=
addresses
.
cbegin
();
auto
&&
it
=
addresses
.
cbegin
();
// It exists at least one sip address.
weight
+=
computeStringWeight
(
...
...
tests/src/components/core/CoreManager.cpp
View file @
a20c32af
...
...
@@ -28,7 +28,5 @@ void CoreManager::setDatabasesPaths () {
database_path
=
Database
::
getMessageHistoryPath
();
if
(
database_path
.
length
()
==
0
)
qFatal
(
"Unable to get message history database path."
);
// FIXME.
// m_core->setChatDatabasePath(database_path);
m_core
->
setChatDatabasePath
(
database_path
);
}
tests/src/components/timeline/TimelineModel.cpp
View file @
a20c32af
#include <algorithm>
#include <QDateTime>
#include <linphone++/linphone.hh>
#include "../../utils.hpp"
#include "../core/CoreManager.hpp"
#include "TimelineModel.hpp"
using
namespace
std
;
// ===================================================================
TimelineModel
::
TimelineModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
// TMP.
m_addresses
<<
"toto.linphone.sip.linphone.org"
;
m_addresses
<<
"toto1.linphone.sip.linphone.org"
;
m_addresses
<<
"toto2.linphone.sip.linphone.org"
;
m_addresses
<<
"toto3.linphone.sip.linphone.org"
;
m_addresses
<<
"toto4.linphone.sip.linphone.org"
;
m_addresses
<<
"toto5.linphone.sip.linphone.org"
;
m_addresses
<<
"toto6.linphone.sip.linphone.org"
;
m_addresses
<<
"toto7.linphone.sip.linphone.org"
;
m_addresses
<<
"toto8.linphone.sip.linphone.org"
;
m_addresses
<<
"toto9.linphone.sip.linphone.org"
;
m_addresses
<<
"toto10.linphone.sip.linphone.org"
;
m_addresses
<<
"toto11.linphone.sip.linphone.org"
;
// Returns an iterator entry position to insert a new entry.
auto
search_entry
=
[
this
](
const
QVariantMap
&
map
,
const
QList
<
QMap
<
QString
,
QVariant
>
>::
iterator
*
start
=
NULL
)
{
return
lower_bound
(
start
?
*
start
:
m_entries
.
begin
(),
m_entries
.
end
(),
map
,
[](
const
QVariantMap
&
a
,
const
QVariantMap
&
b
)
{
return
a
[
"timestamp"
]
<
b
[
"timestamp"
];
}
);
};
shared_ptr
<
linphone
::
Core
>
core
(
CoreManager
::
getInstance
()
->
getCore
());
// Insert chat rooms events.
for
(
auto
&&
chat_room
:
core
->
getChatRooms
())
{
list
<
shared_ptr
<
linphone
::
ChatMessage
>
>
history
=
chat_room
->
getHistory
(
0
);
if
(
history
.
size
()
==
0
)
continue
;
// Last message must be at the end of history.
shared_ptr
<
linphone
::
ChatMessage
>
message
=
history
.
back
();
// Insert event message in timeline entries.
QVariantMap
map
;
map
[
"timestamp"
]
=
QDateTime
::
fromTime_t
(
message
->
getTime
());
map
[
"sipAddresses"
]
=
Utils
::
linphoneStringToQString
(
chat_room
->
getPeerAddress
()
->
asString
()
);
m_entries
.
insert
(
search_entry
(
map
),
map
);
}
// Insert calls events.
QHash
<
QString
,
bool
>
address_done
;
for
(
auto
&&
call_log
:
core
->
getCallLogs
())
{
// Get a sip uri to check.
QString
address
=
Utils
::
linphoneStringToQString
(
call_log
->
getRemoteAddress
()
->
asString
()
);
if
(
address_done
.
value
(
address
))
continue
;
// Already used.
address_done
[
address
]
=
true
;
// Make a new map.
QVariantMap
map
;
map
[
"timestamp"
]
=
QDateTime
::
fromTime_t
(
call_log
->
getStartDate
()
+
call_log
->
getDuration
()
);
map
[
"sipAddresses"
]
=
address
;
// Search existing entry.
auto
&&
it
=
find_if
(
m_entries
.
begin
(),
m_entries
.
end
(),
[
&
address
](
const
QVariantMap
&
map
)
{
return
address
==
map
[
"sipAddresses"
].
toString
();
}
);
// Is it a new entry?
if
(
it
==
m_entries
.
cend
())
m_entries
.
insert
(
search_entry
(
map
),
map
);
else
if
(
map
[
"timestamp"
]
>
(
*
it
)[
"timestamp"
])
{
// Remove old entry and insert.
it
=
m_entries
.
erase
(
it
)
-
1
;
m_entries
.
insert
(
search_entry
(
map
,
&
it
),
map
);
}
}
}
int
TimelineModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m_
address
es
.
count
();
return
m_
entri
es
.
count
();
}
QHash
<
int
,
QByteArray
>
TimelineModel
::
roleNames
()
const
{
...
...
@@ -31,11 +99,11 @@ QHash<int, QByteArray> TimelineModel::roleNames () const {
QVariant
TimelineModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
int
row
=
index
.
row
();
if
(
row
<
0
||
row
>=
m_
address
es
.
count
())
if
(
row
<
0
||
row
>=
m_
entri
es
.
count
())
return
QVariant
();
if
(
role
==
Qt
::
DisplayRole
)
return
QVariant
::
fromValue
(
m_addresses
[
row
])
;
return
m_entries
[
row
]
;
return
QVariant
();
}
tests/src/components/timeline/TimelineModel.hpp
View file @
a20c32af
...
...
@@ -16,7 +16,11 @@ public:
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
private:
QStringList
m_addresses
;
// A timeline enty is a object that contains:
// - A QDateTime `timestamp`.
// - A `sipAddresses` value, if it exists only one address, it's
// a string, otherwise it's a string array.
QList
<
QVariantMap
>
m_entries
;
};
#endif // TIMELINE_MODEL_H_
tests/ui/modules/Linphone/Call/ConnectedCallsControl.qml
View file @
a20c32af
import
QtQuick
2.7
Item
{}
tests/ui/modules/Linphone/Call/IncomingCallControls.qml
View file @
a20c32af
import
QtQuick
2.7
Item
{}
tests/ui/modules/Linphone/Call/OutgoingCallControls.qml
View file @
a20c32af
import
QtQuick
2.7
Item
{}
tests/ui/modules/Linphone/Call/PausedCallControls.qml
View file @
a20c32af
import
QtQuick
2.7
Item
{}
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