diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 28d39fc51..c27d90974 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -58,6 +58,7 @@ set(HEADERS src/components/settings/AccountSettingsModel.hpp src/components/settings/SettingsModel.hpp src/components/timeline/TimelineModel.hpp + src/utils.hpp ) set(QRC_RESOURCES @@ -136,5 +137,7 @@ qt5_add_resources(RESOURCES ${QRC_RESOURCES}) add_executable(${LINPHONE_EXEC} ${SOURCES} ${HEADERS} ${RESOURCES}) add_dependencies(${LINPHONE_EXEC} update_translations) add_dependencies(update_translations check_qml) + target_include_directories(${LINPHONE_EXEC} PRIVATE "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/include/") + target_link_libraries(${LINPHONE_EXEC} ${LIBS}) diff --git a/tests/src/app/Database.hpp b/tests/src/app/Database.hpp index a51c4e905..d1346b787 100644 --- a/tests/src/app/Database.hpp +++ b/tests/src/app/Database.hpp @@ -3,6 +3,8 @@ #include +// =================================================================== + namespace Database { // Returns the databases paths. // If files cannot be created or are unavailable, a empty string is returned. diff --git a/tests/src/components/contacts/ContactModel.cpp b/tests/src/components/contacts/ContactModel.cpp index 9d03a6d7b..c26e2a047 100644 --- a/tests/src/components/contacts/ContactModel.cpp +++ b/tests/src/components/contacts/ContactModel.cpp @@ -25,11 +25,3 @@ Presence::PresenceStatus ContactModel::getPresenceStatus () const { Presence::PresenceLevel ContactModel::getPresenceLevel () const { return Presence::getPresenceLevel(m_presence_status); } - -QStringList ContactModel::getSipAddresses () const { - return m_sip_addresses; -} - -void ContactModel::setSipAddresses (const QStringList &sip_addresses) { - m_sip_addresses = sip_addresses; -} diff --git a/tests/src/components/contacts/ContactModel.hpp b/tests/src/components/contacts/ContactModel.hpp index cade04efb..5c41e0c39 100644 --- a/tests/src/components/contacts/ContactModel.hpp +++ b/tests/src/components/contacts/ContactModel.hpp @@ -2,9 +2,9 @@ #define CONTACT_MODEL_H #include - #include +#include "../../utils.hpp" #include "../presence/Presence.hpp" // =================================================================== @@ -41,16 +41,14 @@ class ContactModel : public QObject { ); Q_PROPERTY( - QStringList sipAddresses - READ getSipAddresses - WRITE setSipAddresses + QString sipAddress + READ getSipAddress NOTIFY contactUpdated ); public: ContactModel (std::shared_ptr linphone_friend) { m_linphone_friend = linphone_friend; - m_sip_addresses << "jiiji"; } signals: @@ -66,13 +64,18 @@ private: Presence::PresenceStatus getPresenceStatus () const; Presence::PresenceLevel getPresenceLevel () const; - QStringList getSipAddresses () const; - void setSipAddresses (const QStringList &sip_addresses); + QString getSipAddress () const { + // FIXME. + return "toto@linphone.org"; + + return Utils::linphoneStringToQString( + m_linphone_friend->getAddress()->asString() + ); + } QString m_username; QString m_avatar; Presence::PresenceStatus m_presence_status = Presence::Offline; - QStringList m_sip_addresses; std::shared_ptr m_linphone_friend; }; diff --git a/tests/src/components/contacts/ContactsListModel.cpp b/tests/src/components/contacts/ContactsListModel.cpp index 79f82e972..ecce79069 100644 --- a/tests/src/components/contacts/ContactsListModel.cpp +++ b/tests/src/components/contacts/ContactsListModel.cpp @@ -8,6 +8,7 @@ ContactsListModel::ContactsListModel (QObject *parent): QAbstractListModel(parent) { std::shared_ptr core(CoreManager::getInstance()->getCore()); + // Init contacts with linphone friends list. for (auto friend_ : core->getFriendsLists().front()->getFriends()) { m_list << new ContactModel(friend_); } diff --git a/tests/src/components/contacts/ContactsListProxyModel.cpp b/tests/src/components/contacts/ContactsListProxyModel.cpp index bb1e6c84c..57751032b 100644 --- a/tests/src/components/contacts/ContactsListProxyModel.cpp +++ b/tests/src/components/contacts/ContactsListProxyModel.cpp @@ -51,9 +51,7 @@ bool ContactsListProxyModel::filterAcceptsRow (int source_row, const QModelIndex index.data() ); - int weight = m_weights[contact] = static_cast( - computeContactWeight(*contact) - ); + int weight = m_weights[contact] = computeContactWeight(*contact); return weight > 0 && ( !m_use_connected_filter || @@ -117,14 +115,23 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel &contact) float weight = computeStringWeight(contact.m_username, USERNAME_WEIGHT); // It exists at least one sip address. - const QStringList &addresses = contact.m_sip_addresses; - weight += computeStringWeight(addresses[0], MAIN_SIP_ADDRESS_WEIGHT); + const std::list > addresses = + contact.m_linphone_friend->getAddresses(); + // FIXME. + return 0; + weight += computeStringWeight(contact.getSipAddress(), MAIN_SIP_ADDRESS_WEIGHT); + + // Compute for other addresses. int size = addresses.size(); + return 0; if (size > 1) - for (auto it = ++addresses.constBegin(); it != addresses.constEnd(); ++it) - weight += computeStringWeight(*it, OTHER_SIP_ADDRESSES_WEIGHT / size); + for (auto it = ++addresses.cbegin(); it != addresses.cend(); ++it) + weight += computeStringWeight( + Utils::linphoneStringToQString((*it)->asString()), + OTHER_SIP_ADDRESSES_WEIGHT / size + ); return weight; } diff --git a/tests/ui/modules/Linphone/Contact/Contact.qml b/tests/ui/modules/Linphone/Contact/Contact.qml index 16ffd5d5c..cf5a57b88 100644 --- a/tests/ui/modules/Linphone/Contact/Contact.qml +++ b/tests/ui/modules/Linphone/Contact/Contact.qml @@ -40,7 +40,7 @@ Rectangle { Layout.fillHeight: true Layout.fillWidth: true - sipAddress: contact.sipAddresses[0] + sipAddress: contact.sipAddress username: avatar.username } diff --git a/tests/ui/views/App/MainWindow/Conversation.qml b/tests/ui/views/App/MainWindow/Conversation.qml index 6c714a883..abac7c263 100644 --- a/tests/ui/views/App/MainWindow/Conversation.qml +++ b/tests/ui/views/App/MainWindow/Conversation.qml @@ -40,7 +40,7 @@ ColumnLayout { ContactDescription { Layout.fillHeight: true Layout.fillWidth: true - sipAddress: contact.sipAddresses[0] + sipAddress: contact.sipAddress sipAddressColor: ConversationStyle.bar.description.sipAddressColor username: contact.username usernameColor: ConversationStyle.bar.description.usernameColor