- Crash when editing contacts from chat.

- Contacts synchronization on creation.
- Contact menu in secure chats.
This commit is contained in:
Julien Wadel 2023-02-02 10:59:33 +01:00
parent 5d1e3bc18f
commit 803e9f7d81
4 changed files with 25 additions and 13 deletions

View file

@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Remove blank notification when declining incoming call.
- Remove blank page when opening calls window and add a waiting step while connecting to call.
- Camera activation issue based on call status.
- Crash when editing contacts from chat.
- Contacts synchronization on creation.
- Contact menu in secure chats.
## 5.0.9 - 2023-01-30

View file

@ -45,8 +45,10 @@ ContactModel::ContactModel (VcardModel *vcardModel, QObject * parent) : QObject(
mLinphoneFriend = linphone::Friend::newFromVcard(vcardModel->mVcard);
mLinphoneFriend->setData("contact-model", *this);
qInfo() << QStringLiteral("Create contact from vcard:") << this << vcardModel;
if(mLinphoneFriend)
qInfo() << QStringLiteral("Create contact from vcard:") << this << vcardModel;
else
qCritical() << QStringLiteral("Friend couldn't be created for vcard:") << this << vcardModel;
setVcardModelInternal(vcardModel);
}

View file

@ -106,6 +106,9 @@ ContactModel *ContactsListModel::getContactModelFromAddress (const QString& addr
}
ContactModel *ContactsListModel::addContact (VcardModel *vcardModel) {
if(!vcardModel)
return nullptr;
// Try to merge vcardModel to an existing contact.
auto contact = findContactModelFromUsername(vcardModel->getUsername());
if (contact) {
@ -115,6 +118,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcardModel) {
contact = QSharedPointer<ContactModel>::create(vcardModel);
App::getInstance()->getEngine()->setObjectOwnership(contact.get(), QQmlEngine::CppOwnership);
addContact(contact);
if( mLinphoneFriends.size() == 0){
update();// Friends were not loaded correctly. Update them.
@ -130,6 +134,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcardModel) {
return nullptr;
}
qInfo() << QStringLiteral("Add contact from vcard:") << contact.get() << vcardModel;
// Make sure new subscribe is issued.
@ -201,16 +206,18 @@ void ContactsListModel::update(){
//------------------------------------------------------------------------------------------------
void ContactsListModel::onContactCreated(const std::shared_ptr<linphone::Friend> & linphoneFriend){
QQmlEngine *engine = App::getInstance()->getEngine();
auto haveContact = std::find_if(mList.begin(), mList.end(), [linphoneFriend] (const QSharedPointer<QObject>& item){
return item.objectCast<ContactModel>()->getFriend() == linphoneFriend;
});
if(haveContact == mList.end()) {
auto contact = QSharedPointer<ContactModel>::create(linphoneFriend);
// See: http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership
// The returned value must have a explicit parent or a QQmlEngine::CppOwnership.
engine->setObjectOwnership(contact.get(), QQmlEngine::CppOwnership);
addContact(contact);
if(linphoneFriend){
QQmlEngine *engine = App::getInstance()->getEngine();
auto haveContact = std::find_if(mList.begin(), mList.end(), [linphoneFriend] (const QSharedPointer<QObject>& item){
return item.objectCast<ContactModel>()->getFriend() == linphoneFriend;
});
if(haveContact == mList.end()) {
auto contact = QSharedPointer<ContactModel>::create(linphoneFriend);
// See: http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership
// The returned value must have a explicit parent or a QQmlEngine::CppOwnership.
engine->setObjectOwnership(contact.get(), QQmlEngine::CppOwnership);
addContact(contact);
}
}
}
void ContactsListModel::onContactDeleted(const std::shared_ptr<linphone::Friend> & linphoneFriend){

View file

@ -400,7 +400,7 @@ ColumnLayout {
iconMenu: editMode ? MenuItemStyle.contact.view : MenuItemStyle.contact.add
iconSizeMenu: 40
menuItemStyle : MenuItemStyle.aux2
visible: conversation.chatRoomModel && SettingsModel.contactsEnabled && !conversation.chatRoomModel.groupEnabled
visible: conversation.chatRoomModel && SettingsModel.contactsEnabled && conversation.chatRoomModel.isOneToOne
onTriggered: {
window.setView('ContactEdit', {
sipAddress: conversation.getFullPeerAddress()