fix crash isme

fix warnings

fix login error message + authentication popup

fix typo

update sdk

replace deprecated function
This commit is contained in:
Gaelle Braud 2024-09-16 15:03:06 +02:00
parent 0315266ef1
commit 654a4a8f50
18 changed files with 144 additions and 125 deletions

View file

@ -60,7 +60,8 @@ ConferenceInfoCore::ConferenceInfoCore(std::shared_ptr<linphone::ConferenceInfo>
mHaveModel = true;
auto confSchedulerModel = mConferenceInfoModel->getConferenceScheduler();
if (!confSchedulerModel) {
auto confScheduler = CoreModel::getInstance()->getCore()->createConferenceScheduler();
auto defaultAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
auto confScheduler = CoreModel::getInstance()->getCore()->createConferenceScheduler(defaultAccount);
confSchedulerModel = Utils::makeQObject_ptr<ConferenceSchedulerModel>(confScheduler);
mConferenceInfoModel->setConferenceScheduler(confSchedulerModel);
}
@ -597,7 +598,7 @@ void ConferenceInfoCore::save() {
auto confInfoModel = Utils::makeQObject_ptr<ConferenceInfoModel>(linphoneConf);
auto confSchedulerModel = confInfoModel->getConferenceScheduler();
if (!confSchedulerModel) {
auto confScheduler = CoreModel::getInstance()->getCore()->createConferenceScheduler();
auto confScheduler = CoreModel::getInstance()->getCore()->createConferenceScheduler(defaultAccount);
confSchedulerModel = Utils::makeQObject_ptr<ConferenceSchedulerModel>(confScheduler);
confInfoModel->setConferenceScheduler(confSchedulerModel);
}

View file

@ -54,7 +54,6 @@ QString LoginPage::getErrorMessage() const {
}
void LoginPage::setErrorMessage(const QString &error) {
// force signal emission to display the error even if it doesn't change
if (mErrorMessage != error) {
mErrorMessage = error;
emit errorMessageChanged(error);
@ -66,6 +65,7 @@ void LoginPage::login(const QString &username,
QString displayName,
QString domain,
LinphoneEnums::TransportType transportType) {
setErrorMessage("");
App::postModelAsync([=]() {
// Create on Model thread.
AccountManager *accountManager = new AccountManager();

View file

@ -38,7 +38,7 @@ public:
void initTimeZones();
int get(const QTimeZone &timeZone = QTimeZone::systemTimeZone()) const;
QHash<int, QByteArray> roleNames() const;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
private:

View file

@ -257,8 +257,8 @@ QStringList SettingsModel::getPlaybackDevices() const {
QString SettingsModel::getCaptureDevice() const {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto audioDevice = CoreModel::getInstance()->getCore()->getInputAudioDevice();
return Utils::coreStringToAppString(audioDevice ? audioDevice->getId()
: CoreModel::getInstance()->getCore()->getCaptureDevice());
if (!audioDevice) audioDevice = CoreModel::getInstance()->getCore()->getDefaultInputAudioDevice();
return Utils::coreStringToAppString(audioDevice ? audioDevice->getId() : "");
}
void SettingsModel::setCaptureDevice(const QString &device) {
@ -269,7 +269,7 @@ void SettingsModel::setCaptureDevice(const QString &device) {
find_if(list.cbegin(), list.cend(),
[&](const std::shared_ptr<linphone::AudioDevice> &audioItem) { return audioItem->getId() == devId; });
if (audioDevice != list.cend()) {
CoreModel::getInstance()->getCore()->setCaptureDevice(devId);
CoreModel::getInstance()->getCore()->setDefaultInputAudioDevice(*audioDevice);
CoreModel::getInstance()->getCore()->setInputAudioDevice(*audioDevice);
emit captureDeviceChanged(device);
resetCaptureGraph();
@ -281,8 +281,8 @@ void SettingsModel::setCaptureDevice(const QString &device) {
QString SettingsModel::getPlaybackDevice() const {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto audioDevice = CoreModel::getInstance()->getCore()->getOutputAudioDevice();
return Utils::coreStringToAppString(audioDevice ? audioDevice->getId()
: CoreModel::getInstance()->getCore()->getPlaybackDevice());
if (!audioDevice) audioDevice = CoreModel::getInstance()->getCore()->getDefaultOutputAudioDevice();
return Utils::coreStringToAppString(audioDevice ? audioDevice->getId() : "");
}
void SettingsModel::setPlaybackDevice(const QString &device) {
@ -294,8 +294,7 @@ void SettingsModel::setPlaybackDevice(const QString &device) {
find_if(list.cbegin(), list.cend(),
[&](const std::shared_ptr<linphone::AudioDevice> &audioItem) { return audioItem->getId() == devId; });
if (audioDevice != list.cend()) {
CoreModel::getInstance()->getCore()->setPlaybackDevice(devId);
CoreModel::getInstance()->getCore()->setDefaultOutputAudioDevice(*audioDevice);
CoreModel::getInstance()->getCore()->setOutputAudioDevice(*audioDevice);
CoreModel::getInstance()->getCore()->setRingerDevice(devId);
emit playbackDeviceChanged(device);
@ -477,9 +476,10 @@ bool SettingsModel::getShowChats() const {
return mConfig->getBool(UiSection, "disable_chat_feature", false);
}*/
// clang-format off
void SettingsModel::notifyConfigReady(){
DEFINE_NOTIFY_CONFIG_READY(assistantGoDirectlyToThirdPartySipAccountLogin,
AssistantGoDirectlyToThirdPartySipAccountLogin)
DEFINE_NOTIFY_CONFIG_READY(assistantGoDirectlyToThirdPartySipAccountLogin,
AssistantGoDirectlyToThirdPartySipAccountLogin)
DEFINE_NOTIFY_CONFIG_READY(assistantThirdPartySipAccountDomain, AssistantThirdPartySipAccountDomain)
DEFINE_NOTIFY_CONFIG_READY(assistantThirdPartySipAccountTransport, AssistantThirdPartySipAccountTransport)
DEFINE_NOTIFY_CONFIG_READY(autoStart, AutoStart)
@ -487,66 +487,67 @@ void SettingsModel::notifyConfigReady(){
DEFINE_GETSET_CONFIG(SettingsModel, bool, Bool, disableChatFeature, DisableChatFeature, "disable_chat_feature", false)
DEFINE_GETSET_CONFIG(
SettingsModel, bool, Bool, disableMeetingsFeature, DisableMeetingsFeature, "disable_meetings_feature", false)
SettingsModel, bool, Bool, disableMeetingsFeature, DisableMeetingsFeature, "disable_meetings_feature", false)
DEFINE_GETSET_CONFIG(SettingsModel,
bool,
Bool,
disableBroadcastFeature,
DisableBroadcastFeature,
"disable_broadcast_feature",
false)
bool,
Bool,
disableBroadcastFeature,
DisableBroadcastFeature,
"disable_broadcast_feature",
false)
DEFINE_GETSET_CONFIG(SettingsModel, bool, Bool, hideSettings, HideSettings, "hide_settings", false)
DEFINE_GETSET_CONFIG(SettingsModel, bool, Bool, hideAccountSettings, HideAccountSettings, "hide_account_settings", false)
DEFINE_GETSET_CONFIG(
SettingsModel, bool, Bool, hideAccountSettings, HideAccountSettings, "hide_account_settings", false)
DEFINE_GETSET_CONFIG(SettingsModel,
bool,
Bool,
disableCallRecordings,
DisableCallRecordings,
"disable_call_recordings_feature",
false)
bool,
Bool,
disableCallRecordings,
DisableCallRecordings,
"disable_call_recordings_feature",
false)
DEFINE_GETSET_CONFIG(SettingsModel,
bool,
Bool,
assistantHideCreateAccount,
AssistantHideCreateAccount,
"assistant_hide_create_account",
false)
bool,
Bool,
assistantHideCreateAccount,
AssistantHideCreateAccount,
"assistant_hide_create_account",
false)
DEFINE_GETSET_CONFIG(SettingsModel,
bool,
Bool,
assistantDisableQrCode,
AssistantDisableQrCode,
"assistant_disable_qr_code",
true)
bool,
Bool,
assistantDisableQrCode,
AssistantDisableQrCode,
"assistant_disable_qr_code",
true)
DEFINE_GETSET_CONFIG(SettingsModel,
bool,
Bool,
assistantHideThirdPartyAccount,
AssistantHideThirdPartyAccount,
"assistant_hide_third_party_account",
false)
bool,
Bool,
assistantHideThirdPartyAccount,
AssistantHideThirdPartyAccount,
"assistant_hide_third_party_account",
false)
DEFINE_GETSET_CONFIG(SettingsModel,
bool,
Bool,
onlyDisplaySipUriUsername,
OnlyDisplaySipUriUsername,
"only_display_sip_uri_username",
false)
bool,
Bool,
onlyDisplaySipUriUsername,
OnlyDisplaySipUriUsername,
"only_display_sip_uri_username",
false)
DEFINE_GETSET_CONFIG(SettingsModel,
bool,
Bool,
darkModeAllowed,
DarkModeAllowed,
"dark_mode_allowed",
false)
bool,
Bool,
darkModeAllowed,
DarkModeAllowed,
"dark_mode_allowed",
false)
DEFINE_GETSET_CONFIG(SettingsModel, int, Int, maxAccount, MaxAccount, "max_account", 0)
DEFINE_GETSET_CONFIG(SettingsModel,
bool,
Bool,
assistantGoDirectlyToThirdPartySipAccountLogin,
AssistantGoDirectlyToThirdPartySipAccountLogin,
"assistant_go_directly_to_third_party_sip_account_login",
false)
bool,
Bool,
assistantGoDirectlyToThirdPartySipAccountLogin,
AssistantGoDirectlyToThirdPartySipAccountLogin,
"assistant_go_directly_to_third_party_sip_account_login",
false)
DEFINE_GETSET_CONFIG_STRING(SettingsModel,
assistantThirdPartySipAccountDomain,
AssistantThirdPartySipAccountDomain,
@ -556,12 +557,12 @@ DEFINE_GETSET_CONFIG_STRING(SettingsModel,
assistantThirdPartySipAccountTransport,
AssistantThirdPartySipAccountTransport,
"assistant_third_party_sip_account_transport",
"TLS")
"TLS")
DEFINE_GETSET_CONFIG(SettingsModel,
bool,
Bool,
autoStart,
AutoStart,
"auto_start",
false)
bool,
Bool,
autoStart,
AutoStart,
"auto_start",
false)
// clang-format on

View file

@ -232,13 +232,13 @@ QString Utils::formatElapsedTime(int seconds, bool dotsSeparator) {
// s, m, h, d, W, M, Y
// 1, 60, 3600, 86400, 604800, 2592000, 31104000
auto y = floor(seconds / 31104000);
if (y > 0) return QString::number(y) + " years";
if (y > 0) return tr("%n year(s)", "", y);
auto M = floor(seconds / 2592000);
if (M > 0) return QString::number(M) + " months";
if (M > 0) return tr("%n month(s)", "", M);
auto w = floor(seconds / 604800);
if (w > 0) return QString::number(w) + " week";
if (w > 0) return tr("%n week(s)", "", w);
auto d = floor(seconds / 86400);
if (d > 0) return QString::number(d) + " days";
if (d > 0) return tr("%n day(s)", "", d);
auto h = floor(seconds / 3600);
auto m = floor((seconds - h * 3600) / 60);
@ -1326,10 +1326,13 @@ int Utils::getYear(const QDate &date) {
return date.year();
}
bool Utils::isMe(const QString &address) {
VariantObject *Utils::isMe(const QString &address) {
bool isMe = false;
App::postModelSync([&isMe, address]() { isMe = ToolModel::isMe(address); });
return isMe;
VariantObject *data = new VariantObject();
if (!data) return nullptr;
data->makeRequest([&isMe, address]() { return QVariant::fromValue(ToolModel::isMe(address)); });
data->requestValue();
return data;
}
bool Utils::isLocal(const QString &address) {
bool isLocal = false;

View file

@ -122,7 +122,7 @@ public:
Q_INVOKABLE static VariantObject *findFriendByAddress(const QString &address);
Q_INVOKABLE static VariantObject *getFriendAddressSecurityLevel(const QString &address);
static QString generateSavedFilename(const QString &from, const QString &to);
Q_INVOKABLE static bool isMe(const QString &address);
Q_INVOKABLE static VariantObject *isMe(const QString &address);
Q_INVOKABLE static bool isLocal(const QString &address);
Q_INVOKABLE static bool isUsername(const QString &txt); // Regex check
static QString getCountryName(const QLocale::Territory &p_country);

View file

@ -39,23 +39,6 @@ ApplicationWindow {
}
}
property bool authenticationPopupOpened: false
Component {
id: authenticationPopupComp
AuthenticationDialog{
property var authenticationDialog
property var callback: authenticationDialog.result
identity: authenticationDialog.username
domain: authenticationDialog.domain
onAccepted: {
authenticationDialog ? authenticationDialog.result(password) : callback(password)
close()
}
onOpened: mainWindow.authenticationPopupOpened = true
onClosed: mainWindow.authenticationPopupOpened = false
}
}
Popup {
id: startCallPopup
property FriendGui contact
@ -238,13 +221,6 @@ ApplicationWindow {
popup.open()
popup.closePopup.connect(removeFromPopupLayout)
}
function reauthenticateAccount(authenticationDialog){
if (authenticationPopupOpened) return
console.log("Showing authentication dialog")
var popup = authenticationPopupComp.createObject(mainWindow, {"authenticationDialog": authenticationDialog})
popup.open()
}
ColumnLayout {
id: popupLayout

View file

@ -68,7 +68,7 @@ Item {
AccountProxy {
id: accountProxy
onDefaultAccountChanged: if (tabbar.currentIndex === 0 && defaultAccount) defaultAccount.core.lResetMissedCalls()
onDefaultAccountChanged: if (tabbar.currentIndex === 0 && defaultAccount) defaultAccount.core?.lResetMissedCalls()
}
CallProxy {
@ -146,7 +146,7 @@ Item {
]
onCurrentIndexChanged: {
SettingsCpp.setLastActiveTabIndex(currentIndex)
if (currentIndex === 0 && accountProxy.defaultAccount) accountProxy.defaultAccount.core.lResetMissedCalls()
if (currentIndex === 0 && accountProxy.defaultAccount) accountProxy.defaultAccount.core?.lResetMissedCalls()
if (mainItem.contextualMenuOpenedComponent) {
closeContextualMenuComponent()
}

View file

@ -56,6 +56,31 @@ AppWindow {
mainWindowStackView.replace(loginPage)
}
property bool authenticationPopupOpened: false
Component {
id: authenticationPopupComp
AuthenticationDialog{
property var authenticationDialog
property var callback: authenticationDialog.result
identity: authenticationDialog.username
domain: authenticationDialog.domain
onAccepted: {
authenticationDialog ? authenticationDialog.result(password) : callback(password)
close()
}
onOpened: mainWindow.authenticationPopupOpened = true
onClosed: mainWindow.authenticationPopupOpened = false
}
}
function reauthenticateAccount(authenticationDialog){
if (mainWindowStackView.currentItem.objectName !== "mainPage") return
if (authenticationPopupOpened) return
console.log("Showing authentication dialog")
var popup = authenticationPopupComp.createObject(mainWindow, {"authenticationDialog": authenticationDialog})
popup.open()
}
Connections {
target: SettingsCpp
function onAssistantGoDirectlyToThirdPartySipAccountLoginChanged() {
@ -168,6 +193,7 @@ AppWindow {
Component {
id: mainPage
MainLayout {
objectName: "mainPage"
onAddAccountRequest: goToLogin()
onAccountRemoved: {
initStackViewItem()

View file

@ -17,7 +17,7 @@ StackView {
property FriendGui contact: null
property CallGui call: null
property string _address: account
? account.core.identityAddress
? account.core?.identityAddress || ""
: call
? call.core.peerAddress
: contact
@ -26,7 +26,7 @@ StackView {
readonly property string address: SettingsCpp.onlyDisplaySipUriUsername ? UtilsCpp.getUsername(_address) : _address
property var displayNameObj: UtilsCpp.getDisplayName(_address)
property string displayNameVal: displayNameObj ? displayNameObj.value : ""
property bool haveAvatar: (account && account.core.pictureUri )
property bool haveAvatar: (account && account.core?.pictureUri || false)
|| (contact && contact.core.pictureUri)
|| computedAvatarUri.length != 0
property string computedAvatarUri: UtilsCpp.findAvatarByAddress(_address)
@ -43,9 +43,11 @@ StackView {
property bool securityBreach: securityLevel === LinphoneEnums.SecurityLevel.Unsafe
property bool displayPresence: (account || contact) && (account
? account.core.registrationState != LinphoneEnums.RegistrationState.Progress && account.core.registrationState != LinphoneEnums.RegistrationState.Refreshing
: contact.core.consolidatedPresence != LinphoneEnums.ConsolidatedPresence.Offline)
property bool displayPresence: account
? account.core?.registrationState != LinphoneEnums.RegistrationState.Progress && account.core?.registrationState != LinphoneEnums.RegistrationState.Refreshing || false
: contact
? contact.core?.consolidatedPresence != LinphoneEnums.ConsolidatedPresence.Offline || false
: false
initialItem: haveAvatar ? avatar : initials
@ -80,11 +82,11 @@ StackView {
anchors.rightMargin: mainItem.width / 15
z: 1
color: account
? account.core.registrationState == LinphoneEnums.RegistrationState.Ok
? account.core?.registrationState == LinphoneEnums.RegistrationState.Ok
? DefaultStyle.success_500main
: account.core.registrationState == LinphoneEnums.RegistrationState.Cleared || account.core.registrationState == LinphoneEnums.RegistrationState.None
: account.core?.registrationState == LinphoneEnums.RegistrationState.Cleared || account.core?.registrationState == LinphoneEnums.RegistrationState.None
? DefaultStyle.warning_600
: account.core.registrationState == LinphoneEnums.RegistrationState.Progress || account.core.registrationState == LinphoneEnums.RegistrationState.Refreshing
: account.core?.registrationState == LinphoneEnums.RegistrationState.Progress || account.core?.registrationState == LinphoneEnums.RegistrationState.Refreshing
? DefaultStyle.main2_500main
: DefaultStyle.danger_500main
: contact

View file

@ -82,7 +82,8 @@ Item {
}
Text {
id: waitingTime
visible: !UtilsCpp.isMe(mainItem.peerAddress)
property var isMeObj: UtilsCpp.isMe(mainItem.peerAddress)
visible: isMeObj ? !isMeObj.value : false
property int seconds
text: UtilsCpp.formatElapsedTime(seconds)
color: DefaultStyle.grey_0

View file

@ -7,6 +7,13 @@ import Linphone
Text {
id: mainItem
color: DefaultStyle.danger_500main
function clear() {
autoHideErrorMessage.stop()
text = ""
}
function setText(text) {
mainItem.text = text
}
font {
pixelSize: 12 * DefaultStyle.dp
weight: 300 * DefaultStyle.dp

View file

@ -43,7 +43,7 @@ ColumnLayout {
Connections {
target: LoginPageCpp
function onErrorMessageChanged() {
errorText.text = LoginPageCpp.errorMessage
errorText.setText(LoginPageCpp.errorMessage)
}
function onRegistrationStateChanged() {
if (LoginPageCpp.registrationState === LinphoneEnums.RegistrationState.Ok) {
@ -101,7 +101,7 @@ ColumnLayout {
function trigger() {
username.errorMessage = ""
password.errorMessage = ""
errorText.text = ""
errorText.clear()
if (usernameEdit.text.length == 0 || passwordEdit.text.length == 0) {
if (usernameEdit.text.length == 0)

View file

@ -21,7 +21,7 @@ ListView {
onCountChanged: selectedConference = model && currentIndex != -1 && currentIndex < model.count ? model.getAt(currentIndex) : null
onCurrentIndexChanged: {
selectedConference = model.getAt(currentIndex)
selectedConference = model.getAt(currentIndex) || null
}
onVisibleChanged: if( visible) {
mainItem.positionViewAtIndex(currentIndex, ListView.Center)// First approximative move

View file

@ -15,7 +15,7 @@ Control.TabBar {
property AccountGui defaultAccount
onDefaultAccountChanged: {
if (defaultAccount) defaultAccount.core.lRefreshNotifications()
if (defaultAccount) defaultAccount.core?.lRefreshNotifications()
}
component UnreadNotification: Rectangle {
@ -94,9 +94,9 @@ Control.TabBar {
unread: !defaultAccount
? -1
: index == 0
? defaultAccount.core.unreadCallNotifications
? defaultAccount.core?.unreadCallNotifications || -1
: index == 2
? defaultAccount.core.unreadMessageNotifications
? defaultAccount.core?.unreadMessageNotifications || -1
: 0
anchors.right: parent.right
anchors.rightMargin: 15 * DefaultStyle.dp

View file

@ -20,8 +20,8 @@ AbstractMainPage {
property ConferenceInfoGui confInfoGui
property AccountProxy accounts: AccountProxy {id: accountProxy}
property AccountGui account: accountProxy.defaultAccount
property var state: account && account.core.registrationState || 0
property bool isRegistered: account ? account.core.registrationState == LinphoneEnums.RegistrationState.Ok : false
property var state: account && account.core?.registrationState || 0
property bool isRegistered: account ? account.core?.registrationState == LinphoneEnums.RegistrationState.Ok : false
property int selectedParticipantsCount
signal startGroupCallRequested()
signal createCallFromSearchBarRequested()

View file

@ -560,7 +560,8 @@ AbstractMainPage {
}
Button {
id: editButton
visible: mainItem.selectedConference && UtilsCpp.isMe(mainItem.selectedConference.core.organizerAddress)
property var isMeObj: UtilsCpp.isMe(mainItem.selectedConference?.core.organizerAddress)
visible: mainItem.selectedConference && isMeObj && isMeObj.value || false
Layout.preferredWidth: 24 * DefaultStyle.dp
Layout.preferredHeight: 24 * DefaultStyle.dp
icon.width: 24 * DefaultStyle.dp
@ -588,6 +589,7 @@ AbstractMainPage {
color: deletePopup.popupBackgroundColor
borderColor: deletePopup.popupBackgroundColor
inversedColors: true
property var isMeObj: UtilsCpp.isMe(mainItem.selectedConference?.core.organizerAddress)
contentItem: RowLayout {
EffectImage {
imageSource: AppIcons.trashCan
@ -609,7 +611,7 @@ AbstractMainPage {
}
onClicked: {
if (mainItem.selectedConference) {
cancelAndDeleteConfDialog.cancel = UtilsCpp.isMe(mainItem.selectedConference.core.organizerAddress)
cancelAndDeleteConfDialog.cancel = isMeObj? isMeObj.value : false
cancelAndDeleteConfDialog.open()
// mainItem.contactDeletionRequested(mainItem.selectedConference)
deletePopup.close()

@ -1 +1 @@
Subproject commit 7f93384a7206b754c1f550751a633ab1e8fee076
Subproject commit 86749bbcd54f72f5405030619ea5c9097dbc54a9