diff --git a/linphone-desktop/CMakeLists.txt b/linphone-desktop/CMakeLists.txt index 60b72a42f..0a2a0c596 100644 --- a/linphone-desktop/CMakeLists.txt +++ b/linphone-desktop/CMakeLists.txt @@ -109,6 +109,7 @@ set(SOURCES src/components/codecs/VideoCodecsModel.cpp src/components/conference/ConferenceAddModel.cpp src/components/conference/ConferenceHelperModel.cpp + src/components/conference/ConferenceModel.cpp src/components/contact/ContactModel.cpp src/components/contact/VcardModel.cpp src/components/contacts/ContactsListModel.cpp @@ -153,6 +154,7 @@ set(HEADERS src/components/Components.hpp src/components/conference/ConferenceAddModel.hpp src/components/conference/ConferenceHelperModel.hpp + src/components/conference/ConferenceModel.hpp src/components/contact/ContactModel.hpp src/components/contact/VcardModel.hpp src/components/contacts/ContactsListModel.hpp diff --git a/linphone-desktop/src/app/App.cpp b/linphone-desktop/src/app/App.cpp index 9949193bf..ada3350c2 100644 --- a/linphone-desktop/src/app/App.cpp +++ b/linphone-desktop/src/app/App.cpp @@ -349,6 +349,7 @@ void App::registerTypes () { registerType("ChatModel"); registerType("ChatProxyModel"); registerType("ConferenceHelperModel"); + registerType("ConferenceModel"); registerType("ContactsListProxyModel"); registerType("SipAddressesProxyModel"); registerType("SoundPlayer"); diff --git a/linphone-desktop/src/components/call/CallModel.cpp b/linphone-desktop/src/components/call/CallModel.cpp index 5abb8a54c..e170a02aa 100644 --- a/linphone-desktop/src/components/call/CallModel.cpp +++ b/linphone-desktop/src/components/call/CallModel.cpp @@ -41,6 +41,8 @@ CallModel::CallModel (shared_ptr call) { mCall = call; mCall->setData("call-model", *this); + updateIsInConference(); + // Deal with auto-answer. { SettingsModel *settings = CoreManager::getInstance()->getSettingsModel(); @@ -254,7 +256,7 @@ void CallModel::handleCallStateChanged (const shared_ptr &call, // ----------------------------------------------------------------------------- void CallModel::updateIsInConference () { - if (mIsInConference != !!mCall->getConference()) { + if (mIsInConference != mCall->getParams()->getLocalConferenceMode()) { mIsInConference = !mIsInConference; emit isInConferenceChanged(mIsInConference); } diff --git a/linphone-desktop/src/components/call/CallModel.hpp b/linphone-desktop/src/components/call/CallModel.hpp index 2828e7ba1..a5816d621 100644 --- a/linphone-desktop/src/components/call/CallModel.hpp +++ b/linphone-desktop/src/components/call/CallModel.hpp @@ -25,7 +25,7 @@ #include #include - +#include // ============================================================================= class CallModel : public QObject { @@ -115,6 +115,7 @@ private: } bool isInConference () const { + qDebug() << "toto" << mIsInConference; return mIsInConference; } diff --git a/linphone-desktop/src/components/conference/ConferenceAddModel.cpp b/linphone-desktop/src/components/conference/ConferenceAddModel.cpp index b257b9513..b2b3edf1d 100644 --- a/linphone-desktop/src/components/conference/ConferenceAddModel.cpp +++ b/linphone-desktop/src/components/conference/ConferenceAddModel.cpp @@ -40,8 +40,10 @@ ConferenceHelperModel::ConferenceAddModel::ConferenceAddModel (QObject *parent) this, &ConferenceAddModel::handleDataChanged ); - for (auto &participant : coreManager->getCore()->getConference()->getParticipants()) - addToConference(participant); + for (const auto &call : coreManager->getCore()->getCalls()) { + if (call->getParams()->getLocalConferenceMode()) + addToConference(call->getRemoteAddress()); + } } int ConferenceHelperModel::ConferenceAddModel::rowCount (const QModelIndex &) const { @@ -68,6 +70,22 @@ QVariant ConferenceHelperModel::ConferenceAddModel::data (const QModelIndex &ind // ----------------------------------------------------------------------------- +bool ConferenceHelperModel::ConferenceAddModel::addToConference (const shared_ptr &linphoneAddress) { + const QString &sipAddress = ::Utils::linphoneStringToQString(linphoneAddress->asStringUriOnly()); + if (mSipAddresses.contains(sipAddress)) + return false; + + int row = rowCount(); + + beginInsertRows(QModelIndex(), row, row); + addToConferencePrivate(linphoneAddress->clone()); + endInsertRows(); + + mConferenceHelperModel->invalidate(); + + return true; +} + bool ConferenceHelperModel::ConferenceAddModel::addToConference (const QString &sipAddress) { if (mSipAddresses.contains(sipAddress)) return false; @@ -80,7 +98,7 @@ bool ConferenceHelperModel::ConferenceAddModel::addToConference (const QString & shared_ptr linphoneAddress = CoreManager::getInstance()->getCore()->interpretUrl( ::Utils::qStringToLinphoneString(sipAddress) ); - addToConference(linphoneAddress); + addToConferencePrivate(linphoneAddress); endInsertRows(); @@ -120,7 +138,19 @@ void ConferenceHelperModel::ConferenceAddModel::update () { linphoneAddresses.push_back(linphoneAddress); } - mConferenceHelperModel->mConference->inviteParticipants( + shared_ptr conference = mConferenceHelperModel->mConference; + + // Remove sip addresses if necessary. + for (const auto &call : CoreManager::getInstance()->getCore()->getCalls()) { + if (!call->getParams()->getLocalConferenceMode()) + continue; + + const QString &sipAddress = ::Utils::linphoneStringToQString(call->getRemoteAddress()->asStringUriOnly()); + if (!mSipAddresses.contains(sipAddress)) + call->terminate(); + } + + conference->inviteParticipants( linphoneAddresses, CoreManager::getInstance()->getCore()->createCallParams(nullptr) ); @@ -128,7 +158,7 @@ void ConferenceHelperModel::ConferenceAddModel::update () { // ----------------------------------------------------------------------------- -void ConferenceHelperModel::ConferenceAddModel::addToConference (const shared_ptr &linphoneAddress) { +void ConferenceHelperModel::ConferenceAddModel::addToConferencePrivate (const shared_ptr &linphoneAddress) { QString sipAddress = ::Utils::linphoneStringToQString(linphoneAddress->asStringUriOnly()); QVariantMap map = CoreManager::getInstance()->getSipAddressesModel()->find(sipAddress); diff --git a/linphone-desktop/src/components/conference/ConferenceAddModel.hpp b/linphone-desktop/src/components/conference/ConferenceAddModel.hpp index 6cbda05a8..60187bad3 100644 --- a/linphone-desktop/src/components/conference/ConferenceAddModel.hpp +++ b/linphone-desktop/src/components/conference/ConferenceAddModel.hpp @@ -26,7 +26,10 @@ #include #include "ConferenceHelperModel.hpp" +#include "ConferenceModel.hpp" +// ============================================================================= +// Sip addresses list to add to conference. // ============================================================================= namespace linphone { @@ -45,6 +48,8 @@ public: QHash roleNames () const override; QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override; + bool addToConference (const std::shared_ptr &linphoneAddress); + Q_INVOKABLE bool addToConference (const QString &sipAddress); Q_INVOKABLE bool removeFromConference (const QString &sipAddress); @@ -55,7 +60,7 @@ public: } private: - void addToConference (const std::shared_ptr &linphoneAddress); + void addToConferencePrivate (const std::shared_ptr &linphoneAddress); void handleDataChanged ( const QModelIndex &topLeft, diff --git a/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp b/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp index 77827cd3e..c65124b8f 100644 --- a/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp +++ b/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp @@ -27,6 +27,9 @@ #include +// ============================================================================= +// Sip addresses not in conference. +// Can filter the sip addresses with a pattern. // ============================================================================= class CallModel; diff --git a/linphone-desktop/src/components/conference/ConferenceModel.cpp b/linphone-desktop/src/components/conference/ConferenceModel.cpp new file mode 100644 index 000000000..5bdbefb38 --- /dev/null +++ b/linphone-desktop/src/components/conference/ConferenceModel.cpp @@ -0,0 +1,49 @@ +/* + * ConferenceModel.cpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: May 23, 2017 + * Author: Ronan Abhamon + */ + +#include "ConferenceModel.hpp" + +// ============================================================================= + +ConferenceModel::ConferenceModel (QObject *parent) : QAbstractListModel(parent) {} + +int ConferenceModel::rowCount (const QModelIndex &index) const { + return mSipAddresses.count(); +} + +QHash ConferenceModel::roleNames () const { + QHash roles; + roles[Qt::DisplayRole] = "$sipAddress"; + return roles; +} + +QVariant ConferenceModel::data (const QModelIndex &index, int role) const { + int row = index.row(); + + if (!index.isValid() || row < 0 || row >= mSipAddresses.count()) + return QVariant(); + + if (role == Qt::DisplayRole) + return mSipAddresses[row]; + + return QVariant(); +} diff --git a/linphone-desktop/src/components/conference/ConferenceModel.hpp b/linphone-desktop/src/components/conference/ConferenceModel.hpp new file mode 100644 index 000000000..72e930d35 --- /dev/null +++ b/linphone-desktop/src/components/conference/ConferenceModel.hpp @@ -0,0 +1,44 @@ +/* + * ConferenceModel.hpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: May 23, 2017 + * Author: Ronan Abhamon + */ + +#ifndef CONFERENCE_MODEL_H_ +#define CONFERENCE_MODEL_H_ + +#include + +// ============================================================================= + +class ConferenceModel : public QAbstractListModel { +public: + ConferenceModel (QObject *parent = Q_NULLPTR); + ~ConferenceModel () = default; + + int rowCount (const QModelIndex &index = QModelIndex()) const override; + + QHash roleNames () const override; + QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override; + +private: + QStringList mSipAddresses; +}; + +#endif // CONFERENCE_MODEL_H_ diff --git a/linphone-desktop/ui/modules/Linphone/Calls/Calls.qml b/linphone-desktop/ui/modules/Linphone/Calls/Calls.qml index 45331096c..233463fcf 100644 --- a/linphone-desktop/ui/modules/Linphone/Calls/Calls.qml +++ b/linphone-desktop/ui/modules/Linphone/Calls/Calls.qml @@ -136,7 +136,7 @@ ListView { readonly property var params: Logic.getParams($call) anchors.centerIn: parent - sourceComponent: params.component + sourceComponent: params ? params.component : null } SequentialAnimation on color { diff --git a/linphone-desktop/ui/views/App/Calls/CallsWindow.qml b/linphone-desktop/ui/views/App/Calls/CallsWindow.qml index 0d434fd9e..b1afd1aa5 100644 --- a/linphone-desktop/ui/views/App/Calls/CallsWindow.qml +++ b/linphone-desktop/ui/views/App/Calls/CallsWindow.qml @@ -19,9 +19,10 @@ Window { // `{}` is a workaround to avoid `TypeError: Cannot read property...`. property var call: calls.selectedCall || ({ + callError: '', isOutgoing: true, - sipAddress: '', recording: false, + sipAddress: '', updating: true, videoEnabled: false })