Display call title in the middle.

Send Video conference invitation in secure chat if possible.
Fix crash on chat room deletion.
This commit is contained in:
Julien Wadel 2022-09-21 17:33:28 +02:00
parent 4fcb0110d0
commit 579893f5f9
12 changed files with 48 additions and 14 deletions

View file

@ -28,7 +28,9 @@
ChatRoomListener::ChatRoomListener(QObject * parent): QObject(parent){
}
ChatRoomListener::~ChatRoomListener(){
qDebug() << "Destroying ChatRoomListener " << this;
}
//---------------------------------------------------------------------------------------------------
void ChatRoomListener::onIsComposingReceived(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::Address> & remoteAddress, bool isComposing){

View file

@ -34,7 +34,7 @@ class ChatRoomListener : public QObject, public linphone::ChatRoomListener {
Q_OBJECT
public:
ChatRoomListener(QObject * parent = nullptr);
virtual ~ChatRoomListener(){}
virtual ~ChatRoomListener();
virtual void onIsComposingReceived(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::Address> & remoteAddress, bool isComposing) override;
virtual void onMessageReceived(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<linphone::ChatMessage> & message) override;

View file

@ -439,15 +439,15 @@ bool ChatRoomModel::isOneToOne() const{
}
bool ChatRoomModel::isMeAdmin() const{
return mChatRoom->getMe()->isAdmin();
return mChatRoom && mChatRoom->getMe()->isAdmin();
}
bool ChatRoomModel::isCurrentAccount() const{
return Utils::isMe(mChatRoom->getLocalAddress());
return mChatRoom && Utils::isMe(mChatRoom->getLocalAddress());
}
bool ChatRoomModel::canHandleParticipants() const{
return mChatRoom->canHandleParticipants();
return mChatRoom && mChatRoom->canHandleParticipants();
}
bool ChatRoomModel::getIsRemoteComposing () const {
@ -601,6 +601,8 @@ void ChatRoomModel::markAsToDelete(){
void ChatRoomModel::deleteChatRoom(){
qInfo() << "Deleting ChatRoom : " << getSubject() << ", address=" << getFullPeerAddress();
CoreManager::getInstance()->getCore()->deleteChatRoom(mChatRoom);
mChatRoom->removeListener(mChatRoomListener);
emit chatRoomDeleted();
}
void ChatRoomModel::leaveChatRoom (){
@ -702,10 +704,13 @@ void ChatRoomModel::compose () {
void ChatRoomModel::resetMessageCount () {
if(mChatRoom && !mDeleteChatRoom && markAsReadEnabled()){
if (mChatRoom->getUnreadMessagesCount() > 0){
mChatRoom->markAsRead();// Marking as read is only for messages. Not for calls.
}
setUnreadMessagesCount(mChatRoom->getUnreadMessagesCount());
if( mChatRoom->getState() != linphone::ChatRoom::State::Deleted){
if (mChatRoom->getUnreadMessagesCount() > 0){
mChatRoom->markAsRead();// Marking as read is only for messages. Not for calls.
}
setUnreadMessagesCount(mChatRoom->getUnreadMessagesCount());
}else
setUnreadMessagesCount(0);
setMissedCallsCount(0);
emit messageCountReset();
CoreManager::getInstance()->updateUnreadMessageCount();

View file

@ -269,7 +269,8 @@ void ChatRoomProxyModel::reload (ChatRoomModel *chatRoomModel) {
QObject::disconnect(ChatRoomModel, &ChatRoomModel::messageReceived, this, &ChatRoomProxyModel::handleMessageReceived);
QObject::disconnect(ChatRoomModel, &ChatRoomModel::messageSent, this, &ChatRoomProxyModel::handleMessageSent);
QObject::disconnect(ChatRoomModel, &ChatRoomModel::markAsReadEnabledChanged, this, &ChatRoomProxyModel::markAsReadEnabledChanged);
QObject::disconnect(ChatRoomModel, &ChatRoomModel::moreEntriesLoaded, this, &ChatRoomProxyModel::onMoreEntriesLoaded);
QObject::disconnect(ChatRoomModel, &ChatRoomModel::moreEntriesLoaded, this, &ChatRoomProxyModel::onMoreEntriesLoaded);
QObject::disconnect(ChatRoomModel, &ChatRoomModel::chatRoomDeleted, this, &ChatRoomProxyModel::chatRoomDeleted);
if(mIsCall)
mChatRoomModel->removeBindingCall();
}
@ -287,6 +288,7 @@ void ChatRoomProxyModel::reload (ChatRoomModel *chatRoomModel) {
QObject::connect(ChatRoomModel, &ChatRoomModel::messageSent, this, &ChatRoomProxyModel::handleMessageSent);
QObject::connect(ChatRoomModel, &ChatRoomModel::markAsReadEnabledChanged, this, &ChatRoomProxyModel::markAsReadEnabledChanged);
QObject::connect(ChatRoomModel, &ChatRoomModel::moreEntriesLoaded, this, &ChatRoomProxyModel::onMoreEntriesLoaded);
QObject::connect(ChatRoomModel, &ChatRoomModel::chatRoomDeleted, this, &ChatRoomProxyModel::chatRoomDeleted);
mChatRoomModel->initEntries();// This way, we don't load huge chat rooms (that lead to freeze GUI)
}
}

View file

@ -88,6 +88,7 @@ signals:
//bool isSecureChanged(bool secure);
void chatRoomModelChanged();
void chatRoomDeleted();
void moreEntriesLoaded (int n);

View file

@ -25,6 +25,7 @@
#include "app/App.hpp"
#include "components/core/CoreHandlers.hpp"
#include "components/core/CoreManager.hpp"
#include "components/settings/SettingsModel.hpp"
void ConferenceScheduler::connectTo(ConferenceSchedulerListener * listener){
connect(listener, &ConferenceSchedulerListener::stateChanged, this, &ConferenceScheduler::onStateChanged);
@ -61,7 +62,10 @@ void ConferenceScheduler::onStateChanged(linphone::ConferenceScheduler::State st
emit CoreManager::getInstance()->getHandlers()->conferenceInfoReceived(mConferenceScheduler->getInfo());
if( (mSendInvite & 1) == 1){
std::shared_ptr<linphone::ChatRoomParams> params = CoreManager::getInstance()->getCore()->createDefaultChatRoomParams();
params->setBackend(linphone::ChatRoomBackend::Basic);
if( CoreManager::getInstance()->getSettingsModel()->getSecureChatEnabled())
params->setBackend(linphone::ChatRoomBackend::FlexisipChat);
else
params->setBackend(linphone::ChatRoomBackend::Basic);
mConferenceScheduler->sendInvitations(params);
}
}

View file

@ -68,6 +68,7 @@ TimelineListModel::TimelineListModel(const TimelineListModel* model){
for(auto item : model->mList) {
auto newItem = qobject_cast<TimelineModel*>(item)->clone();
connect(newItem.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool)));
connect(newItem.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted);
connect(newItem->getChatRoomModel(), &ChatRoomModel::allEntriesRemoved, this, &TimelineListModel::removeChatRoomModel);
mList << newItem;
}
@ -295,6 +296,7 @@ void TimelineListModel::updateTimelines () {
void TimelineListModel::add (QSharedPointer<TimelineModel> timeline){
auto chatRoomModel = timeline->getChatRoomModel();
auto chatRoom = chatRoomModel->getChatRoom();
connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted);
if( !chatRoomModel->haveConferenceAddress() || chatRoom->getHistoryEventsSize() != 0) {
connect(chatRoomModel, &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineListModel::updated);
ProxyListModel::add(timeline);
@ -398,3 +400,7 @@ void TimelineListModel::onCallCreated(const std::shared_ptr<linphone::Call> &cal
}
}
}
void TimelineListModel::onChatRoomDeleted(){
remove(sender());
}

View file

@ -65,6 +65,7 @@ public slots:
void onChatRoomStateChanged(const std::shared_ptr<linphone::ChatRoom> &chatRoom,linphone::ChatRoom::State state);
void onCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::Call::State state) ;
void onCallCreated(const std::shared_ptr<linphone::Call> &call);
void onChatRoomDeleted();
signals:
void countChanged();

View file

@ -113,6 +113,7 @@ TimelineModel::TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, QObj
CoreManager::getInstance()->handleChatRoomCreated(mChatRoomModel);
QObject::connect(this, &TimelineModel::selectedChanged, this, &TimelineModel::updateUnreadCount);
QObject::connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultAccountChanged, this, &TimelineModel::onDefaultAccountChanged);
QObject::connect(mChatRoomModel.get(), &ChatRoomModel::chatRoomDeleted, this, &TimelineModel::onChatRoomDeleted);
}
if(chatRoom){
mChatRoomListener = std::make_shared<ChatRoomListener>(this);
@ -128,6 +129,7 @@ TimelineModel::TimelineModel(const TimelineModel * model){
if( mChatRoomModel ){
QObject::connect(this, &TimelineModel::selectedChanged, this, &TimelineModel::updateUnreadCount);
QObject::connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultAccountChanged, this, &TimelineModel::onDefaultAccountChanged);
QObject::connect(mChatRoomModel.get(), &ChatRoomModel::chatRoomDeleted, this, &TimelineModel::onChatRoomDeleted);
}
if(mChatRoomModel->getChatRoom()){
mChatRoomListener = model->mChatRoomListener;
@ -201,7 +203,7 @@ void TimelineModel::onDefaultAccountChanged(){
}
void TimelineModel::disconnectChatRoomListener(){
if( mChatRoomModel && mChatRoomListener){
if( mChatRoomModel && mChatRoomListener && mChatRoomModel->getChatRoom()){
mChatRoomModel->getChatRoom()->removeListener(mChatRoomListener);
}
}
@ -251,3 +253,7 @@ void TimelineModel::onParticipantRegistrationSubscriptionRequested(const std::sh
void TimelineModel::onParticipantRegistrationUnsubscriptionRequested(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<const linphone::Address> & participantAddress){}
void TimelineModel::onChatMessageShouldBeStored(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<linphone::ChatMessage> & message){}
void TimelineModel::onChatMessageParticipantImdnStateChanged(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<linphone::ChatMessage> & message, const std::shared_ptr<const linphone::ParticipantImdnState> & state){}
void TimelineModel::onChatRoomDeleted(){
emit chatRoomDeleted();
}

View file

@ -100,6 +100,7 @@ public:
public slots:
void updateUnreadCount();
void onDefaultAccountChanged();
void onChatRoomDeleted();
signals:
void fullPeerAddressChanged();
@ -109,6 +110,7 @@ signals:
void presenceStatusChanged();
void selectedChanged(bool selected);
void conferenceLeft();
void chatRoomDeleted();
private:

View file

@ -67,7 +67,7 @@ Item {
titleColor: isSelected
? TimelineStyle.contact.title.color.selected
: TimelineStyle.contact.title.color.normal
showSubtitle: mainItem.timelineModel.chatRoomModel && (mainItem.timelineModel.chatRoomModel.isOneToOne || !mainItem.timelineModel.chatRoomModel.isConference)
showSubtitle: mainItem.timelineModel && (mainItem.timelineModel.chatRoomModel && (mainItem.timelineModel.chatRoomModel.isOneToOne || !mainItem.timelineModel.chatRoomModel.isConference))
TooltipArea {
id: contactTooltip
text: mainItem.timelineModel && UtilsCpp.toDateTimeString(mainItem.timelineModel.chatRoomModel.lastUpdateTime)

View file

@ -184,8 +184,13 @@ Rectangle {
Item{
Layout.fillWidth: true
Layout.preferredHeight: title.contentHeight + address.contentHeight
property int centerOffset: mapFromItem(mainItem, mainItem.width/2,0).x - width/2 // Compute center from mainItem
ColumnLayout{
anchors.fill: parent
anchors.top: parent.top
anchors.bottom: parent.bottom
width: parent.width
x: parent.centerOffset
Text{
id: title
Layout.alignment: Qt.AlignHCenter