linphone-desktop/linphone-app/ui/scripts/LinphoneUtils/linphone-utils.js
Julien Wadel 73733c17a0 * 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.
2021-10-20 17:12:12 +02:00

123 lines
3.6 KiB
JavaScript

/*
* Copyright (c) 2010-2020 Belledonne Communications SARL.
*
* This file is part of linphone-desktop
* (see https://www.linphone.org).
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
// =============================================================================
// Contains linphone helpers.
// =============================================================================
.pragma library
.import Linphone 1.0 as Linphone
.import UtilsCpp 1.0 as UtilsCpp
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
// =============================================================================
// Contact/SIP address helpers.
// =============================================================================
function _getDisplayNameFromQuotedString (str) {
var start = str.indexOf('"')
if (start === -1) {
return
}
var end = str.lastIndexOf('"')
if (end === -1 || start === end) {
return
}
return str.substring(start + 1, end)
}
function _getDisplayNameFromString (str) {
var end = str.indexOf('<')
if (end === -1) {
return
}
return str.substring(0, end).trim() || undefined
}
function _getDisplayName (str) {
var name = _getDisplayNameFromQuotedString(str)
if (name != null) {
return name
}
return _getDisplayNameFromString(str)
}
// -----------------------------------------------------------------------------
function _getUsername (str) {
var start = str.indexOf('sip')
if (start === -1) {
return
}
start += 4 + Number(str.charAt(start + 4) === ':') // Deal with `sip:` and `sips:`
var end = str.indexOf('@', start + 1)
if (end === -1) {
return Utils.decode(str.substring(start))
}
return Utils.decode(str.substring(start, end))
}
// =============================================================================
// Codec helpers.
// =============================================================================
function openCodecOnlineInstallerDialog (window, codecInfo, cb) {
var VideoCodecsModel = Linphone.VideoCodecsModel
window.attachVirtualWindow(Utils.buildDialogUri('ConfirmDialog'), {
descriptionText: qsTr('downloadCodecDescription')
.replace('%1', codecInfo.mime)
.replace('%2', codecInfo.encoderDescription)
}, function (status) {
if (status) {
window.attachVirtualWindow(buildDialogUri('OnlineInstallerDialog'), {
downloadUrl: codecInfo.downloadUrl,
extract: true,
installFolder: VideoCodecsModel.codecsFolder,
installName: codecInfo.installName,
mime: codecInfo.mime
}, function (status) {
if (status) {
VideoCodecsModel.reload()
}
if (cb) {
cb(window)
}
})
}
else if (cb) {
cb(window)
}
})
}
// =============================================================================
// QML helpers.
// =============================================================================
function buildDialogUri (component) {
return 'qrc:/ui/modules/Linphone/Dialog/' + component + '.qml'
}