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
9813baf1
Commit
9813baf1
authored
Dec 30, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): add a `ContactObserver` component
parent
ed17343d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
74 additions
and
21 deletions
+74
-21
CMakeLists.txt
tests/CMakeLists.txt
+2
-2
App.cpp
tests/src/app/App.cpp
+2
-2
ContactObserver.cpp
tests/src/components/contact/ContactObserver.cpp
+14
-0
ContactObserver.hpp
tests/src/components/contact/ContactObserver.hpp
+11
-7
SipAddressesModel.cpp
tests/src/components/sip-addresses/SipAddressesModel.cpp
+32
-0
SipAddressesModel.hpp
tests/src/components/sip-addresses/SipAddressesModel.hpp
+7
-0
Chat.qml
tests/ui/modules/Linphone/Chat/Chat.qml
+1
-3
IncomingMessage.qml
tests/ui/modules/Linphone/Chat/IncomingMessage.qml
+2
-2
Incall.qml
tests/ui/views/App/Calls/Incall.qml
+3
-5
No files found.
tests/CMakeLists.txt
View file @
9813baf1
...
...
@@ -58,6 +58,7 @@ set(SOURCES
src/components/camera/Camera.cpp
src/components/chat/ChatModel.cpp
src/components/chat/ChatProxyModel.cpp
src/components/contact/ContactObserver.cpp
src/components/contact/ContactModel.cpp
src/components/contact/VcardModel.cpp
src/components/contacts/ContactsListModel.cpp
...
...
@@ -66,7 +67,6 @@ set(SOURCES
src/components/notifier/Notifier.cpp
src/components/settings/AccountSettingsModel.cpp
src/components/settings/SettingsModel.cpp
src/components/sip-address/SipAddressModel.cpp
src/components/sip-addresses/SipAddressesModel.cpp
src/components/smart-search-bar/SmartSearchBarModel.cpp
src/components/timeline/TimelineModel.cpp
...
...
@@ -82,6 +82,7 @@ set(HEADERS
src/components/camera/Camera.hpp
src/components/chat/ChatModel.hpp
src/components/chat/ChatProxyModel.hpp
src/components/contact/ContactObserver.hpp
src/components/contact/ContactModel.hpp
src/components/contact/VcardModel.hpp
src/components/contacts/ContactsListModel.hpp
...
...
@@ -91,7 +92,6 @@ set(HEADERS
src/components/presence/Presence.hpp
src/components/settings/AccountSettingsModel.hpp
src/components/settings/SettingsModel.hpp
src/components/sip-address/SipAddressModel.hpp
src/components/sip-addresses/SipAddressesModel.hpp
src/components/smart-search-bar/SmartSearchBarModel.hpp
src/components/timeline/TimelineModel.hpp
...
...
tests/src/app/App.cpp
View file @
9813baf1
...
...
@@ -89,8 +89,8 @@ void App::registerTypes () {
qmlRegisterUncreatableType
<
ContactModel
>
(
"Linphone"
,
1
,
0
,
"ContactModel"
,
"ContactModel is uncreatable"
);
qmlRegisterUncreatableType
<
SipAddressModel
>
(
"Linphone"
,
1
,
0
,
"
SipAddressModel"
,
"SipAddressModel
is uncreatable"
qmlRegisterUncreatableType
<
ContactObserver
>
(
"Linphone"
,
1
,
0
,
"
ContactObserver"
,
"ContactObserver
is uncreatable"
);
qmlRegisterUncreatableType
<
VcardModel
>
(
"Linphone"
,
1
,
0
,
"VcardModel"
,
"VcardModel is uncreatable"
...
...
tests/src/components/
sip-address/SipAddressModel
.cpp
→
tests/src/components/
contact/ContactObserver
.cpp
View file @
9813baf1
#include "../contact/ContactModel.hpp"
#include "
SipAddressModel
.hpp"
#include "
ContactObserver
.hpp"
// =============================================================================
SipAddressModel
::
SipAddressModel
()
{
// TODO
ContactObserver
::
ContactObserver
(
const
QString
&
sip_address
)
{
m_sip_address
=
sip_address
;
}
void
ContactObserver
::
setContact
(
ContactModel
*
contact
)
{
m_contact
=
contact
;
emit
contactChanged
(
contact
);
}
tests/src/components/
sip-address/SipAddressModel
.hpp
→
tests/src/components/
contact/ContactObserver
.hpp
View file @
9813baf1
#ifndef
SIP_ADDRESS_MODEL
_H_
#define
SIP_ADDRESS_MODEL
_H_
#ifndef
CONTACT_OBSERVER
_H_
#define
CONTACT_OBSERVER
_H_
#include <QObject>
...
...
@@ -7,15 +7,17 @@
class
ContactModel
;
class
SipAddressModel
:
public
QObject
{
class
ContactObserver
:
public
QObject
{
friend
class
SipAddressesModel
;
Q_OBJECT
;
Q_PROPERTY
(
QString
sipAddress
READ
getSipAddress
CONSTANT
);
Q_PROPERTY
(
ContactModel
*
contact
READ
getContact
NOTIFY
contactChanged
);
public:
SipAddressModel
(
);
~
SipAddressModel
()
=
default
;
ContactObserver
(
const
QString
&
sip_address
);
~
ContactObserver
()
=
default
;
ContactModel
*
getContact
()
const
{
return
m_contact
;
...
...
@@ -29,10 +31,12 @@ private:
return
m_sip_address
;
}
void
setContact
(
ContactModel
*
contact
);
QString
m_sip_address
;
ContactModel
*
m_contact
=
nullptr
;
};
Q_DECLARE_METATYPE
(
SipAddressModel
*
);
Q_DECLARE_METATYPE
(
ContactObserver
*
);
#endif //
SIP_ADDRESS_MODEL
_H_
#endif //
CONTACT_OBSERVER
_H_
tests/src/components/sip-addresses/SipAddressesModel.cpp
View file @
9813baf1
...
...
@@ -115,6 +115,24 @@ void SipAddressesModel::handleAllHistoryEntriesRemoved () {
// -----------------------------------------------------------------------------
ContactObserver
*
SipAddressesModel
::
getContactObserver
(
const
QString
&
sip_address
)
{
ContactObserver
*
model
=
new
ContactObserver
(
sip_address
);
model
->
setContact
(
mapSipAddressToContact
(
sip_address
));
m_observers
.
insert
(
sip_address
,
model
);
QObject
::
connect
(
model
,
&
ContactObserver
::
destroyed
,
this
,
[
this
,
model
]()
{
const
QString
&
sip_address
=
model
->
getSipAddress
();
if
(
m_observers
.
remove
(
sip_address
,
model
)
==
0
)
qWarning
()
<<
QStringLiteral
(
"Unable to remove sip address `%1` from observers."
).
arg
(
sip_address
);
}
);
return
model
;
}
// -----------------------------------------------------------------------------
bool
SipAddressesModel
::
removeRow
(
int
row
,
const
QModelIndex
&
parent
)
{
return
removeRows
(
row
,
1
,
parent
);
}
...
...
@@ -130,6 +148,7 @@ bool SipAddressesModel::removeRows (int row, int count, const QModelIndex &paren
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
const
QVariantMap
*
map
=
m_refs
.
takeAt
(
row
);
QString
sip_address
=
(
*
map
)[
"sipAddress"
].
toString
();
qInfo
()
<<
QStringLiteral
(
"Remove sip address: `%1`."
).
arg
(
sip_address
);
m_sip_addresses
.
remove
(
sip_address
);
}
...
...
@@ -153,6 +172,8 @@ void SipAddressesModel::updateFromNewContactSipAddress (ContactModel *contact, c
map
[
"sipAddress"
]
=
sip_address
;
map
[
"contact"
]
=
QVariant
::
fromValue
(
contact
);
updateObservers
(
sip_address
,
contact
);
int
row
=
m_refs
.
count
();
beginInsertRows
(
QModelIndex
(),
row
,
row
);
...
...
@@ -172,6 +193,8 @@ void SipAddressesModel::updateFromNewContactSipAddress (ContactModel *contact, c
// Sip address exists, update contact.
(
*
it
)[
"contact"
]
=
QVariant
::
fromValue
(
contact
);
updateObservers
(
sip_address
,
contact
);
int
row
=
m_refs
.
indexOf
(
&
(
*
it
));
Q_ASSERT
(
row
!=
-
1
);
emit
dataChanged
(
index
(
row
,
0
),
index
(
row
,
0
));
...
...
@@ -184,6 +207,8 @@ void SipAddressesModel::tryToRemoveSipAddress (const QString &sip_address) {
return
;
}
updateObservers
(
sip_address
,
nullptr
);
if
(
it
->
remove
(
"contact"
)
==
0
)
qWarning
()
<<
QStringLiteral
(
"`contact` field is empty on sip address: `%1`."
).
arg
(
sip_address
);
...
...
@@ -250,3 +275,10 @@ void SipAddressesModel::fetchSipAddresses () {
for
(
auto
&
contact
:
CoreManager
::
getInstance
()
->
getContactsListModel
()
->
m_list
)
updateFromNewContact
(
contact
);
}
void
SipAddressesModel
::
updateObservers
(
const
QString
&
sip_address
,
ContactModel
*
contact
)
{
for
(
auto
&
observer
:
m_observers
.
values
(
sip_address
))
{
if
(
contact
!=
observer
->
getContact
())
observer
->
setContact
(
contact
);
}
}
tests/src/components/sip-addresses/SipAddressesModel.hpp
View file @
9813baf1
...
...
@@ -4,6 +4,7 @@
#include <QAbstractListModel>
#include "../contact/ContactModel.hpp"
#include "../contact/ContactObserver.hpp"
// =============================================================================
...
...
@@ -23,6 +24,8 @@ public slots:
ContactModel
*
mapSipAddressToContact
(
const
QString
&
sip_address
)
const
;
void
handleAllHistoryEntriesRemoved
();
ContactObserver
*
getContactObserver
(
const
QString
&
sip_address
);
private:
bool
removeRow
(
int
row
,
const
QModelIndex
&
parent
=
QModelIndex
());
bool
removeRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
=
QModelIndex
())
override
;
...
...
@@ -33,8 +36,12 @@ private:
void
fetchSipAddresses
();
void
updateObservers
(
const
QString
&
sip_address
,
ContactModel
*
contact
);
QHash
<
QString
,
QVariantMap
>
m_sip_addresses
;
QList
<
const
QVariantMap
*>
m_refs
;
QMultiHash
<
QString
,
ContactObserver
*>
m_observers
;
};
#endif // SIP_ADDRESSES_MODEL_H_
tests/ui/modules/Linphone/Chat/Chat.qml
View file @
9813baf1
...
...
@@ -11,9 +11,7 @@ import Linphone.Styles 1.0
ColumnLayout
{
property
alias
proxyModel
:
chat
.
model
property
var
_contact
:
SipAddressesModel
.
mapSipAddressToContact
(
proxyModel
.
sipAddress
)
||
proxyModel
.
sipAddress
property
var
_contactObserver
:
SipAddressesModel
.
getContactObserver
(
proxyModel
.
sipAddress
)
// ---------------------------------------------------------------------------
...
...
tests/ui/modules/Linphone/Chat/IncomingMessage.qml
View file @
9813baf1
...
...
@@ -20,8 +20,8 @@ RowLayout {
Avatar
{
anchors.centerIn
:
parent
height
:
ChatStyle
.
entry
.
message
.
incoming
.
avatarSize
image
:
_contact
.
avatar
username
:
LinphoneUtils
.
getContactUsername
(
_contact
)
image
:
_contact
Observer
.
contact
?
_contactObserver
.
contact
.
avatar
:
''
username
:
LinphoneUtils
.
getContactUsername
(
_contact
Observer
.
contact
||
_contactObserver
.
sipAddress
)
width
:
ChatStyle
.
entry
.
message
.
incoming
.
avatarSize
}
}
...
...
tests/ui/views/App/Calls/Incall.qml
View file @
9813baf1
...
...
@@ -16,9 +16,7 @@ Rectangle {
property
bool
isVideoCall
:
false
property
string
sipAddress
property
var
_contact
:
SipAddressesModel
.
mapSipAddressToContact
(
sipAddress
)
||
sipAddress
property
var
_contactObserver
:
SipAddressesModel
.
getContactObserver
(
sipAddress
)
// ---------------------------------------------------------------------------
...
...
@@ -58,7 +56,7 @@ Rectangle {
anchors.centerIn
:
parent
horizontalTextAlignment
:
Text
.
AlignHCenter
sipAddress
:
call
.
sipAddress
username
:
LinphoneUtils
.
getContactUsername
(
_contact
)
username
:
LinphoneUtils
.
getContactUsername
(
_contact
Observer
.
contact
||
call
.
sipAddress
)
height
:
parent
.
height
width
:
parent
.
width
-
cameraActions
.
width
-
callQuality
.
width
-
150
...
...
@@ -110,7 +108,7 @@ Rectangle {
}
backgroundColor
:
StartingCallStyle
.
avatar
.
backgroundColor
image
:
_contact
.
vcard
.
avatar
image
:
_contact
Observer
.
contact
?
_contactObserver
.
contact
.
vcard
.
avatar
:
''
username
:
contactDescription
.
username
height
:
_computeAvatarSize
()
...
...
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