* UTF8 fixes and display names behavior:

- Avoid to replace display if empty on address books search
- Propagate change when display name is set in callModel
- Add a way to update addresses when data model change outside of ChatRoomModel
- While calling and one participant, get display name from call remote address
- Update display names after adding a call log
- Fix UTF8 when compute display name
- Replace JS display name functions by CPP

* Fix tooltips width and timeline unexistant object
* MSYS2 bzip2 may block the process execution when no arguments. Add help args and remove outputs from streams.
This commit is contained in:
Julien Wadel 2021-10-18 19:03:36 +02:00
parent 8d9c3d28df
commit 59c2ba9f11
25 changed files with 91 additions and 102 deletions

View file

@ -100,6 +100,7 @@ QString CallModel::getPeerAddress () const {
QString CallModel::getLocalAddress () const {
return Utils::coreStringToAppString(mCall->getCallLog()->getLocalAddress()->asStringUriOnly());
}
QString CallModel::getFullPeerAddress () const {
return Utils::coreStringToAppString(mRemoteAddress->asString());
}
@ -668,7 +669,9 @@ void CallModel::searchReceived(std::list<std::shared_ptr<linphone::SearchResult>
}
}else{
if((*it)->getAddress()->weakEqual(mRemoteAddress)){
setRemoteDisplayName((*it)->getAddress()->getDisplayName());
std::string newDisplayName = (*it)->getAddress()->getDisplayName();
if(!newDisplayName.empty())// Override only if there is one
setRemoteDisplayName(newDisplayName);
found = true;
}
}
@ -702,6 +705,9 @@ void CallModel::setRemoteDisplayName(const std::string& name){
callLog->setRemoteAddress(Utils::interpretUrl(getFullPeerAddress()));
}
emit fullPeerAddressChanged();
ChatRoomModel * model = getChatRoomModel();
if(model)
model->emitFullPeerAddressChanged();
}
QString CallModel::getTransferAddress () const {

View file

@ -220,29 +220,26 @@ ChatRoomModel::ChatRoomModel (std::shared_ptr<linphone::ChatRoom> chatRoom, QObj
QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &ChatRoomModel::handleCallStateChanged);
QObject::connect(coreHandlers, &CoreHandlers::presenceStatusReceived, this, &ChatRoomModel::handlePresenceStatusReceived);
//QObject::connect(coreHandlers, &CoreHandlers::isComposingChanged, this, &ChatRoomModel::handleIsComposingChanged);
QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactAdded, this, &ChatRoomModel::usernameChanged);
QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactAdded, this, &ChatRoomModel::fullPeerAddressChanged);
QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactAdded, this, &ChatRoomModel::avatarChanged);
QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactRemoved, this, &ChatRoomModel::usernameChanged);
QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactRemoved, this, &ChatRoomModel::fullPeerAddressChanged);
QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactRemoved, this, &ChatRoomModel::avatarChanged);
QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactUpdated, this, &ChatRoomModel::usernameChanged);
QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactUpdated, this, &ChatRoomModel::fullPeerAddressChanged);
QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactUpdated, this, &ChatRoomModel::avatarChanged);
connect(this, &ChatRoomModel::fullPeerAddressChanged, this, &ChatRoomModel::usernameChanged);
//QObject::connect(this, &ChatRoomModel::messageCountReset, coreManager, &CoreManager::eventCountChanged );
if(mChatRoom){
mParticipantListModel = std::make_shared<ParticipantListModel>(this);
connect(mParticipantListModel.get(), &ParticipantListModel::participantsChanged, this, &ChatRoomModel::fullPeerAddressChanged);
connect(mParticipantListModel.get(), &ParticipantListModel::participantsChanged, this, &ChatRoomModel::usernameChanged);
auto participants = mChatRoom->getParticipants();
for(auto participant : participants){
auto contact = CoreManager::getInstance()->getContactsListModel()->findContactModelFromSipAddress(Utils::coreStringToAppString((participant)->getAddress()->asString()));
if(contact) {
connect(contact, &ContactModel::contactUpdated, this, &ChatRoomModel::fullPeerAddressChanged);
connect(contact, &ContactModel::contactUpdated, this, &ChatRoomModel::usernameChanged);
}
}
}else
@ -354,6 +351,10 @@ void ChatRoomModel::removeEntry(ChatEvent* entry){
removeRow(row);
}
}
void ChatRoomModel::emitFullPeerAddressChanged(){
emit fullPeerAddressChanged();
}
//--------------------------------------------------------------------------------------------
QString ChatRoomModel::getPeerAddress () const {
@ -403,6 +404,13 @@ QString ChatRoomModel::getUsername () const {
if(username != "")
return username;
if( mChatRoom->getNbParticipants() == 1 ) {
auto call = mChatRoom->getCall();
if(call)
username = Utils::getDisplayName(call->getRemoteAddress());
if(username != "")
return username;
}
if( mChatRoom->getNbParticipants() >= 1)
username = mParticipantListModel->displayNamesToString();
if(username != "")
@ -854,6 +862,8 @@ void ChatRoomModel::callEnded(std::shared_ptr<linphone::Call> call){
else{
insertCall(call->getCallLog());
}
// When a call is end, a new log WILL be written in database. It may have information on display name.
QTimer::singleShot(100, this, &ChatRoomModel::fullPeerAddressChanged);
}
// -----------------------------------------------------------------------------

View file

@ -269,6 +269,8 @@ public slots:
void removeEntry(ChatEvent* entry);
void emitFullPeerAddressChanged(); // Use to call signal when changing data that are not managed by the chat room (like data coming from call)
signals:
bool isRemoteComposingChanged ();

View file

@ -60,10 +60,15 @@ void FileExtractor::extract () {
}
#ifdef WIN32
// Test the presence of bzip2 in the system
int result = QProcess::execute("bzip2.exe", QStringList());
if( result != -2 || QProcess::execute(Utils::coreStringToAppString(Paths::getToolsDirPath())+"\\bzip2.exe", QStringList())!=-2){
QProcess process;
process.closeReadChannel(QProcess::StandardOutput);
process.closeReadChannel(QProcess::StandardError);
process.start("bzip2.exe",QStringList("--help") );
//int result = QProcess::execute("bzip2.exe", QStringList("--help"));
if( process.error() != QProcess::FailedToStart || QProcess::execute(Utils::coreStringToAppString(Paths::getToolsDirPath())+"\\bzip2.exe", QStringList())!=-2){
mTimer->start();
}else{// Download bzip2
qWarning() << "bzip2 was not found. Downloading it.";
QTimer * timer = mTimer;
FileDownloader * fileDownloader = new FileDownloader();
int downloadStep = 0;

View file

@ -481,9 +481,9 @@ QString Utils::getDisplayName(const std::shared_ptr<const linphone::Address>& ad
return cl->getRemoteAddress()->weakEqual(address);
});
if(callLog != callHistory.end())
displayName = Utils::coreStringToAppString((*callLog)->getRemoteAddress()->getDisplayName());
displayName = QString::fromStdString((*callLog)->getRemoteAddress()->getDisplayName());
if(displayName == "")
displayName = Utils::coreStringToAppString(address->getDisplayName());
displayName = QString::fromStdString(address->getDisplayName());
if(displayName == "")
displayName = Utils::coreStringToAppString(address->getUsername());
}

View file

@ -12,7 +12,7 @@ MouseArea {
property int delay: TooltipStyle.delay
property bool force: false
property var tooltipParent: parent
property int maxWidth : window.width
property int maxWidth : window? window.width : tooltipParent.width
property bool _visible: false
property int hoveringCursor : Qt.PointingHandCursor

View file

@ -24,6 +24,7 @@
.import QtQuick 2.7 as QtQuick
.import Linphone 1.0 as Linphone
.import UtilsCpp 1.0 as UtilsCpp
.import 'qrc:/ui/scripts/LinphoneUtils/linphone-utils.js' as LinphoneUtils
@ -50,18 +51,6 @@ function getComponentFromEntry (chatEntry) {
return chatEntry.isOutgoing ? 'OutgoingMessage.qml' : 'IncomingMessage.qml'
}
function getIsComposingMessage () {
if (!container.proxyModel.isRemoteComposing || !Linphone.SettingsModel.chatEnabled) {
return ''
}
var sipAddressObserver = chat.sipAddressObserver
return qsTr('isComposing').replace(
'%1',
LinphoneUtils.getContactUsername(sipAddressObserver)
)
}
function handleFilesDropped (files) {
chat.bindToEnd = true
files.forEach(container.proxyModel.sendFileMessage)

View file

@ -5,6 +5,7 @@ import QtQuick.Layouts 1.3
import Common 1.0
import Linphone 1.0
import Linphone.Styles 1.0
import UtilsCpp 1.0
import 'Chat.js' as Logic

View file

@ -62,7 +62,6 @@ Rectangle {
)
:-1
//username: LinphoneUtils.getContactUsername(_contact || entry.sipAddress || entry.fullPeerAddress || entry.peerAddress || '')
//username: UtilsCpp.getDisplayName(entry.sipAddress || entry.peerAddress )
username : entry!=undefined && entry.isOneToOne!=undefined && !entry.isOneToOne ? '' : item.username

View file

@ -5,6 +5,7 @@ import Linphone 1.0
import LinphoneUtils 1.0
import Linphone.Styles 1.0
import Utils 1.0
import UtilsCpp 1.0
// =============================================================================
@ -87,7 +88,7 @@ Row {
pointSize: HistoryStyle.entry.event.text.pointSize
}
height: parent.height
text: LinphoneUtils.getContactUsername(_sipAddressObserver)
text: UtilsCpp.getDisplayName(_sipAddressObserver.peerAddress)
verticalAlignment: Text.AlignVCenter
MouseArea{
anchors.fill:parent

View file

@ -257,7 +257,7 @@ Rectangle {
isClickable: true
}
Icon{
icon: modelData.selected ? 'timer_light' : 'timer'
icon: modelData && modelData.selected ? 'timer_light' : 'timer'
iconSize: 15
anchors.right:parent.right
anchors.bottom:parent.bottom

View file

@ -24,6 +24,7 @@
.pragma library
.import Linphone 1.0 as Linphone
.import UtilsCpp 1.0 as UtilsCpp
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
@ -80,37 +81,6 @@ function _getUsername (str) {
return Utils.decode(str.substring(start, end))
}
// -----------------------------------------------------------------------------
// Returns the username of a contact/sipAddressObserver object or URI string.
function getContactUsername (contact) {
if(contact){
var object = contact.contact || // Contact object from `SipAddressObserver`.
(contact.vcard && contact) // Contact object.
// 1. `object` is a contact.
if (object) {
return object.vcard.username
}
// 2. `object` is just a string.
object = Utils.isString(contact.peerAddress)
? contact.peerAddress // String from `SipAddressObserver`.
: contact // Just a String.
// Use display name.
var name = _getDisplayName(object)
if (name != null) {
return name
}
// Use username.
name = _getUsername(object)
return name == null ? 'Bad EGG' : name
}else
return '';
}
// =============================================================================
// Codec helpers.
// =============================================================================

View file

@ -5,6 +5,8 @@ import Common 1.0
import Linphone 1.0
import LinphoneUtils 1.0
import UtilsCpp 1.0
import App.Styles 1.0
// =============================================================================
@ -42,7 +44,7 @@ Rectangle {
height: CallStyle.header.contactDescription.height
horizontalTextAlignment: Text.AlignHCenter
sipAddress: call.peerAddress
username: LinphoneUtils.getContactUsername(_sipAddressObserver)
username: UtilsCpp.getDisplayName(_sipAddressObserver.peerAddress)
width: contentWidth
}

View file

@ -6,6 +6,8 @@ import Common.Styles 1.0
import Linphone 1.0
import LinphoneUtils 1.0
import UtilsCpp 1.0
import App.Styles 1.0
// =============================================================================
@ -135,7 +137,7 @@ Rectangle {
horizontalTextAlignment: Text.AlignHCenter
sipAddress: parent.sipAddress
username: LinphoneUtils.getContactUsername(parent._sipAddressObserver)
username: UtilsCpp.getDisplayName(parent._sipAddressObserver.peerAddress)
}
IncallAvatar {

View file

@ -4,6 +4,7 @@ import QtQuick.Layouts 1.3
import Linphone 1.0
import LinphoneUtils 1.0
import Utils 1.0
import UtilsCpp 1.0
import App.Styles 1.0
@ -38,7 +39,7 @@ Rectangle {
horizontalTextAlignment: Text.AlignHCenter
sipAddress: _sipAddressObserver.peerAddress
username: LinphoneUtils.getContactUsername(_sipAddressObserver)
username: UtilsCpp.getDisplayName(_sipAddressObserver.peerAddress)
}
Text {

View file

@ -7,6 +7,7 @@ import Common.Styles 1.0
import Linphone 1.0
import LinphoneUtils 1.0
import Utils 1.0
import UtilsCpp 1.0
import App.Styles 1.0
@ -126,7 +127,7 @@ Rectangle {
anchors.centerIn: parent
horizontalTextAlignment: Text.AlignHCenter
sipAddress: _sipAddressObserver.peerAddress
username: LinphoneUtils.getContactUsername(_sipAddressObserver)
username: UtilsCpp.getDisplayName(sipAddress)
height: parent.height
width: parent.width - rightActions.width - leftActions.width

View file

@ -3,6 +3,8 @@ import QtQuick 2.7
import Linphone 1.0
import LinphoneUtils 1.0
import UtilsCpp 1.0
import App.Styles 1.0
// =============================================================================
@ -11,7 +13,7 @@ Avatar {
property var call
readonly property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call.fullPeerAddress, call.fullLocalAddress)
readonly property var _username: LinphoneUtils.getContactUsername(_sipAddressObserver)
readonly property var _username: UtilsCpp.getDisplayName(_sipAddressObserver.peerAddress)
backgroundColor: CallStyle.container.avatar.backgroundColor
foregroundColor: call.status === CallModel.CallStatusPaused

View file

@ -22,6 +22,7 @@
// =============================================================================
.import Linphone 1.0 as Linphone
.import UtilsCpp 1.0 as UtilsCpp
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
.import 'qrc:/ui/scripts/LinphoneUtils/linphone-utils.js' as LinphoneUtils
@ -48,31 +49,6 @@ function handleContactUpdated () {
}
}
function handleCreation () {
var sipAddress = contactEdit.sipAddress
var contact = contactEdit._contact = Linphone.SipAddressesModel.mapSipAddressToContact(
sipAddress
)
if (!contact) {
// Add a new contact.
var vcard = Linphone.CoreManager.createDetachedVcardModel()
if (sipAddress && sipAddress.length > 0) {
vcard.addSipAddress(sipAddress)
vcard.username = LinphoneUtils.getContactUsername(Linphone.SipAddressesModel.getSipAddressObserver(sipAddress, sipAddress))
}else{
vcard.username = ' '// Username initialization to avoid Belr parsing issue when setting new name
}
contactEdit._vcard = vcard
contactEdit._edition = true
} else {
// See or edit a contact.
contactEdit._vcard = contact.vcard
}
}
function handleVcardChanged (vcard) {
if (!vcard) {
vcard = {}

View file

@ -7,6 +7,8 @@ import Common 1.0
import Linphone 1.0
import Linphone.Styles 1.0
import UtilsCpp 1.0
import App.Styles 1.0
import 'ContactEdit.js' as Logic
@ -28,7 +30,30 @@ ColumnLayout {
spacing: 0
Component.onCompleted: Logic.handleCreation()
Component.onCompleted:{
var sipAddress = contactEdit.sipAddress
var contact = contactEdit._contact = SipAddressesModel.mapSipAddressToContact(
sipAddress
)
if (!contact) {
// Add a new contact.
var vcard = CoreManager.createDetachedVcardModel()
if (sipAddress && sipAddress.length > 0) {
vcard.addSipAddress(sipAddress)
vcard.username = UtilsCpp.getDisplayName(SipAddressesModel.getSipAddressObserver(sipAddress, sipAddress).peerAddress)
}else{
vcard.username = ' '// Username initialization to avoid Belr parsing issue when setting new name
}
contactEdit._vcard = vcard
contactEdit._edition = true
} else {
// See or edit a contact.
contactEdit._vcard = contact.vcard
}
}
onVcardChanged: Logic.handleVcardChanged(vcard)

View file

@ -4,6 +4,7 @@ import QtQuick.Layouts 1.3
import Common 1.0
import Linphone 1.0
import Utils 1.0
import UtilsCpp 1.0
import LinphoneEnums 1.0
import App.Styles 1.0

View file

@ -22,6 +22,7 @@
// =============================================================================
.import Linphone 1.0 as Linphone
.import UtilsCpp 1.0 as UtilsCpp
.import 'qrc:/ui/scripts/LinphoneUtils/linphone-utils.js' as LinphoneUtils
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
@ -51,10 +52,6 @@ function getEditTooltipText() {
return conversation._sipAddressObserver.contact ? qsTr('tooltipContactEdit') : qsTr('tooltipContactAdd')
}
function getUsername () {
return LinphoneUtils.getContactUsername(conversation._sipAddressObserver)
}
function updateChatFilter (button) {
var ChatRoomModel = Linphone.ChatRoomModel
if (button === 0) {
@ -72,4 +69,4 @@ function openConferenceManager (params) {
App.smartShowWindow(callsWindow)
callsWindow.openConferenceManager(params)
}
}

View file

@ -88,7 +88,7 @@ ColumnLayout {
presenceLevel: chatRoomModel.presenceStatus
//username: Logic.getUsername()
username: chatRoomModel?chatRoomModel.username:Logic.getUsername()
username: chatRoomModel?chatRoomModel.username:UtilsCpp.getDisplayName(conversation._sipAddressObserver.peerAddress)
visible: !groupChat.visible
}

View file

@ -4,6 +4,7 @@ import QtQuick.Layouts 1.3
import Common 1.0
import Linphone 1.0
import Utils 1.0
import UtilsCpp 1.0
import LinphoneUtils 1.0
import LinphoneEnums 1.0
@ -67,7 +68,7 @@ DialogPlus {
Layout.leftMargin: 14
username: modelData?(modelData.contactModel ? modelData.contactModel.vcard.username
:modelData.username?modelData.username:
LinphoneUtils.getContactUsername(modelData.sipAddress)
UtilsCpp.getDisplayName(modelData.sipAddress)
):''
Icon{
property int securityLevel : modelData.securityLevel
@ -201,4 +202,4 @@ DialogPlus {
}
}
}
}
}

View file

@ -22,6 +22,7 @@
// =============================================================================
.import Linphone 1.0 as Linphone
.import UtilsCpp 1.0 as UtilsCpp
.import 'qrc:/ui/scripts/LinphoneUtils/linphone-utils.js' as LinphoneUtils
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
@ -51,10 +52,6 @@ function getEditTooltipText() {
return historyView._sipAddressObserver && historyView._sipAddressObserver.contact ? qsTr('tooltipContactEdit') : qsTr('tooltipContactAdd')
}
function getUsername () {
return LinphoneUtils.getContactUsername(historyView._sipAddressObserver)
}
function updateHistoryFilter (button) {
var HistoryModel = Linphone.HistoryModel
if (button === 0) {

View file

@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3
import Common 1.0
import Linphone 1.0
import UtilsCpp 1.0
import App.Styles 1.0
@ -55,7 +56,7 @@ ColumnLayout {
historyView._sipAddressObserver.presenceStatus
):null
username: peerAddress?Logic.getUsername():null
username: peerAddress? UtilsCpp.getDisplayName(historyView._sipAddressObserver.peerAddress):null
visible:peerAddress
}