Freeze fixes:
- Unstuck Friends processes. - Unstuck interpret urls. - Unstuck Utils functions that need Model to work. INVOKABLE should not block and use VariantObjects. - rename file local constants. - Upgrade SafeObject to have a default value after being construct. - Fix isMe changes and updates. - Remove restoreMode that is deprecated.
This commit is contained in:
parent
5f2cfde69b
commit
df7f0a6bc6
15 changed files with 127 additions and 77 deletions
|
|
@ -180,7 +180,7 @@ void ConferenceInfoCore::setSelf(QSharedPointer<ConferenceInfoCore> me) {
|
||||||
});
|
});
|
||||||
mConfInfoModelConnection->makeConnectToCore(&ConferenceInfoCore::lCancelConferenceInfo, [this]() {
|
mConfInfoModelConnection->makeConnectToCore(&ConferenceInfoCore::lCancelConferenceInfo, [this]() {
|
||||||
mConfInfoModelConnection->invokeToModel([this] {
|
mConfInfoModelConnection->invokeToModel([this] {
|
||||||
if (Utils::isMe(mOrganizerAddress)) {
|
if (ToolModel::isMe(mOrganizerAddress)) {
|
||||||
mConferenceInfoModel->cancelConference();
|
mConferenceInfoModel->cancelConference();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,14 @@
|
||||||
|
|
||||||
#include "FriendCore.hpp"
|
#include "FriendCore.hpp"
|
||||||
#include "core/App.hpp"
|
#include "core/App.hpp"
|
||||||
#include "core/proxy/ListProxy.hpp"
|
|
||||||
#include "model/tool/ToolModel.hpp"
|
#include "model/tool/ToolModel.hpp"
|
||||||
#include "tool/Utils.hpp"
|
#include "tool/Utils.hpp"
|
||||||
#include "tool/thread/SafeConnection.hpp"
|
#include "tool/thread/SafeConnection.hpp"
|
||||||
|
|
||||||
DEFINE_ABSTRACT_OBJECT(FriendCore)
|
DEFINE_ABSTRACT_OBJECT(FriendCore)
|
||||||
|
|
||||||
const QString addressLabel = FriendCore::tr("Adresse SIP");
|
const QString _addressLabel = FriendCore::tr("Adresse SIP");
|
||||||
const QString phoneLabel = FriendCore::tr("Téléphone");
|
const QString _phoneLabel = FriendCore::tr("Téléphone");
|
||||||
|
|
||||||
QVariant createFriendAddressVariant(const QString &label, const QString &address) {
|
QVariant createFriendAddressVariant(const QString &label, const QString &address) {
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
|
|
@ -73,7 +72,7 @@ FriendCore::FriendCore(const std::shared_ptr<linphone::Friend> &contact) : QObje
|
||||||
auto addresses = contact->getAddresses();
|
auto addresses = contact->getAddresses();
|
||||||
for (auto &address : addresses) {
|
for (auto &address : addresses) {
|
||||||
mAddressList.append(
|
mAddressList.append(
|
||||||
createFriendAddressVariant(addressLabel, Utils::coreStringToAppString(address->asStringUriOnly())));
|
createFriendAddressVariant(_addressLabel, Utils::coreStringToAppString(address->asStringUriOnly())));
|
||||||
}
|
}
|
||||||
mDefaultAddress =
|
mDefaultAddress =
|
||||||
contact->getAddress() ? Utils::coreStringToAppString(contact->getAddress()->asStringUriOnly()) : QString();
|
contact->getAddress() ? Utils::coreStringToAppString(contact->getAddress()->asStringUriOnly()) : QString();
|
||||||
|
|
@ -176,8 +175,8 @@ void FriendCore::setSelf(QSharedPointer<FriendCore> me) {
|
||||||
auto numbers = mFriendModel->getAddresses();
|
auto numbers = mFriendModel->getAddresses();
|
||||||
QList<QVariant> addr;
|
QList<QVariant> addr;
|
||||||
for (auto &num : numbers) {
|
for (auto &num : numbers) {
|
||||||
addr.append(
|
addr.append(createFriendAddressVariant(_addressLabel,
|
||||||
createFriendAddressVariant(addressLabel, Utils::coreStringToAppString(num->asStringUriOnly())));
|
Utils::coreStringToAppString(num->asStringUriOnly())));
|
||||||
}
|
}
|
||||||
mFriendModelConnection->invokeToCore([this, addr]() { resetPhoneNumbers(addr); });
|
mFriendModelConnection->invokeToCore([this, addr]() { resetPhoneNumbers(addr); });
|
||||||
});
|
});
|
||||||
|
|
@ -186,7 +185,7 @@ void FriendCore::setSelf(QSharedPointer<FriendCore> me) {
|
||||||
QList<QVariant> addr;
|
QList<QVariant> addr;
|
||||||
for (auto &num : numbers) {
|
for (auto &num : numbers) {
|
||||||
addr.append(
|
addr.append(
|
||||||
createFriendAddressVariant(phoneLabel, Utils::coreStringToAppString(num->getPhoneNumber())));
|
createFriendAddressVariant(_phoneLabel, Utils::coreStringToAppString(num->getPhoneNumber())));
|
||||||
}
|
}
|
||||||
mFriendModelConnection->invokeToCore([this, addr]() { resetPhoneNumbers(addr); });
|
mFriendModelConnection->invokeToCore([this, addr]() { resetPhoneNumbers(addr); });
|
||||||
});
|
});
|
||||||
|
|
@ -353,15 +352,26 @@ QVariant FriendCore::getAddressAt(int index) const {
|
||||||
return mAddressList[index];
|
return mAddressList[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendCore::setAddressAt(int index, const QString &label, QString address) {
|
void FriendCore::setAddressAt(int index, QString label, QString address) {
|
||||||
if (index < 0 || index >= mAddressList.count()) return;
|
if (index < 0 || index >= mAddressList.count()) return;
|
||||||
auto map = mAddressList[index].toMap();
|
auto map = mAddressList[index].toMap();
|
||||||
|
label = label.isEmpty() ? map["label"].toString() : label;
|
||||||
|
QString currentAddress = map["address"].toString();
|
||||||
|
|
||||||
if (Utils::isUsername(address)) {
|
if (Utils::isUsername(address)) {
|
||||||
address = Utils::interpretUrl(address);
|
mCoreModelConnection->invokeToModel([this, index, label, currentAddress, address]() {
|
||||||
|
auto linphoneAddr = ToolModel::interpretUrl(address);
|
||||||
|
QString interpretedAddr = Utils::coreStringToAppString(linphoneAddr->asStringUriOnly());
|
||||||
|
if (interpretedAddr != currentAddress) {
|
||||||
|
mCoreModelConnection->invokeToCore([this, index, label, interpretedAddr]() {
|
||||||
|
mAddressList.replace(index, createFriendAddressVariant(label, interpretedAddr));
|
||||||
|
emit addressChanged();
|
||||||
|
setIsSaved(false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
auto oldLabel = map["label"].toString();
|
});
|
||||||
if (/*oldLabel != label || */ map["address"] != address) {
|
} else if (address != currentAddress) {
|
||||||
mAddressList.replace(index, createFriendAddressVariant(label.isEmpty() ? oldLabel : label, address));
|
mAddressList.replace(index, createFriendAddressVariant(label, address));
|
||||||
emit addressChanged();
|
emit addressChanged();
|
||||||
setIsSaved(false);
|
setIsSaved(false);
|
||||||
}
|
}
|
||||||
|
|
@ -377,14 +387,18 @@ void FriendCore::removeAddress(int index) {
|
||||||
|
|
||||||
void FriendCore::appendAddress(const QString &addr) {
|
void FriendCore::appendAddress(const QString &addr) {
|
||||||
if (addr.isEmpty()) return;
|
if (addr.isEmpty()) return;
|
||||||
QString interpretedAddress = Utils::interpretUrl(addr);
|
mCoreModelConnection->invokeToModel([this, addr]() {
|
||||||
auto linAddr = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(interpretedAddress));
|
auto linphoneAddr = ToolModel::interpretUrl(addr);
|
||||||
if (!linAddr) Utils::showInformationPopup(tr("Erreur"), tr("Adresse invalide"), false);
|
QString interpretedAddress = linphoneAddr ? Utils::coreStringToAppString(linphoneAddr->asString()) : "";
|
||||||
|
mCoreModelConnection->invokeToCore([this, interpretedAddress]() {
|
||||||
|
if (interpretedAddress.isEmpty()) Utils::showInformationPopup(tr("Erreur"), tr("Adresse invalide"), false);
|
||||||
else {
|
else {
|
||||||
mAddressList.append(createFriendAddressVariant(addressLabel, interpretedAddress));
|
mAddressList.append(createFriendAddressVariant(_addressLabel, interpretedAddress));
|
||||||
if (mDefaultAddress.isEmpty()) mDefaultAddress = interpretedAddress;
|
if (mDefaultAddress.isEmpty()) mDefaultAddress = interpretedAddress;
|
||||||
emit addressChanged();
|
emit addressChanged();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendCore::resetAddresses(QList<QVariant> newList) {
|
void FriendCore::resetAddresses(QList<QVariant> newList) {
|
||||||
|
|
@ -535,7 +549,7 @@ void FriendCore::writeFromModel(const std::shared_ptr<FriendModel> &model) {
|
||||||
QList<QVariant> addresses;
|
QList<QVariant> addresses;
|
||||||
for (auto &addr : model->getAddresses()) {
|
for (auto &addr : model->getAddresses()) {
|
||||||
addresses.append(
|
addresses.append(
|
||||||
createFriendAddressVariant(addressLabel, Utils::coreStringToAppString(addr->asStringUriOnly())));
|
createFriendAddressVariant(_addressLabel, Utils::coreStringToAppString(addr->asStringUriOnly())));
|
||||||
}
|
}
|
||||||
mAddressList = addresses;
|
mAddressList = addresses;
|
||||||
|
|
||||||
|
|
@ -667,5 +681,6 @@ void FriendCore::setIsLdap(bool data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FriendCore::getReadOnly() const {
|
bool FriendCore::getReadOnly() const {
|
||||||
return getIsLdap(); // TODO add conditions for friends retrieved via HTTP [misc]vcards-contacts-list=<URL> & CardDAV
|
return getIsLdap(); // TODO add conditions for friends retrieved via HTTP [misc]vcards-contacts-list=<URL> &
|
||||||
|
// CardDAV
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ public:
|
||||||
QVariant getAddressAt(int index) const;
|
QVariant getAddressAt(int index) const;
|
||||||
Q_INVOKABLE void appendAddress(const QString &addr);
|
Q_INVOKABLE void appendAddress(const QString &addr);
|
||||||
Q_INVOKABLE void removeAddress(int index);
|
Q_INVOKABLE void removeAddress(int index);
|
||||||
Q_INVOKABLE void setAddressAt(int index, const QString &label, QString address);
|
Q_INVOKABLE void setAddressAt(int index, QString label, QString address);
|
||||||
|
|
||||||
void setDefaultAddress(const QString &address);
|
void setDefaultAddress(const QString &address);
|
||||||
QString getDefaultAddress() const;
|
QString getDefaultAddress() const;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include "ParticipantCore.hpp"
|
#include "ParticipantCore.hpp"
|
||||||
// #include "ParticipantDeviceList.hpp"
|
// #include "ParticipantDeviceList.hpp"
|
||||||
#include "model/participant/ParticipantModel.hpp"
|
#include "model/participant/ParticipantModel.hpp"
|
||||||
|
#include "model/tool/ToolModel.hpp"
|
||||||
#include "tool/Utils.hpp"
|
#include "tool/Utils.hpp"
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
@ -46,6 +47,7 @@ ParticipantCore::ParticipantCore(const std::shared_ptr<linphone::Participant> &p
|
||||||
if (participant) {
|
if (participant) {
|
||||||
mAdminStatus = participant->isAdmin();
|
mAdminStatus = participant->isAdmin();
|
||||||
mSipAddress = Utils::coreStringToAppString(participant->getAddress()->asStringUriOnly());
|
mSipAddress = Utils::coreStringToAppString(participant->getAddress()->asStringUriOnly());
|
||||||
|
mIsMe = ToolModel::isMe(mSipAddress);
|
||||||
mCreationTime = QDateTime::fromSecsSinceEpoch(participant->getCreationTime());
|
mCreationTime = QDateTime::fromSecsSinceEpoch(participant->getCreationTime());
|
||||||
mDisplayName = Utils::coreStringToAppString(participant->getAddress()->getDisplayName());
|
mDisplayName = Utils::coreStringToAppString(participant->getAddress()->getDisplayName());
|
||||||
if (mDisplayName.isEmpty())
|
if (mDisplayName.isEmpty())
|
||||||
|
|
@ -58,11 +60,8 @@ ParticipantCore::ParticipantCore(const std::shared_ptr<linphone::Participant> &p
|
||||||
map.insert("address", address);
|
map.insert("address", address);
|
||||||
mParticipantDevices.append(map);
|
mParticipantDevices.append(map);
|
||||||
}
|
}
|
||||||
}
|
} else mIsMe = false;
|
||||||
// App::getInstance()->mEngine->setObjectOwnership(mParticipantDevices.get(),
|
connect(this, &ParticipantCore::sipAddressChanged, this, &ParticipantCore::updateIsMe);
|
||||||
// QQmlEngine::CppOwnership); // Managed by QSharedPointer
|
|
||||||
// connect(this, &ParticipantCore::deviceSecurityLevelChanged, mParticipantDevices.get(),
|
|
||||||
// &ParticipantDeviceListModel::securityLevelChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticipantCore::~ParticipantCore() {
|
ParticipantCore::~ParticipantCore() {
|
||||||
|
|
@ -86,7 +85,20 @@ int ParticipantCore::getDeviceCount() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParticipantCore::isMe() const {
|
bool ParticipantCore::isMe() const {
|
||||||
return Utils::isMe(mSipAddress);
|
return mIsMe;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParticipantCore::setIsMe(bool isMe) {
|
||||||
|
if (mIsMe != isMe) {
|
||||||
|
mIsMe = isMe;
|
||||||
|
emit isMeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParticipantCore::updateIsMe() {
|
||||||
|
mParticipantConnection->invokeToModel([this, address = mSipAddress]() {
|
||||||
|
mParticipantConnection->invokeToCore([this, isMe = ToolModel::isMe(address)]() { setIsMe(isMe); });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ParticipantCore::getSipAddress() const {
|
QString ParticipantCore::getSipAddress() const {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class ParticipantCore : public QObject, public AbstractObject {
|
||||||
Q_PROPERTY(QString sipAddress READ getSipAddress WRITE setSipAddress NOTIFY sipAddressChanged)
|
Q_PROPERTY(QString sipAddress READ getSipAddress WRITE setSipAddress NOTIFY sipAddressChanged)
|
||||||
Q_PROPERTY(QString displayName READ getDisplayName WRITE setDisplayName NOTIFY displayNameChanged)
|
Q_PROPERTY(QString displayName READ getDisplayName WRITE setDisplayName NOTIFY displayNameChanged)
|
||||||
Q_PROPERTY(bool isAdmin READ isAdmin WRITE setIsAdmin NOTIFY isAdminChanged)
|
Q_PROPERTY(bool isAdmin READ isAdmin WRITE setIsAdmin NOTIFY isAdminChanged)
|
||||||
Q_PROPERTY(bool isMe READ isMe CONSTANT)
|
Q_PROPERTY(bool isMe READ isMe NOTIFY isMeChanged)
|
||||||
Q_PROPERTY(QDateTime creationTime READ getCreationTime CONSTANT)
|
Q_PROPERTY(QDateTime creationTime READ getCreationTime CONSTANT)
|
||||||
Q_PROPERTY(bool focus READ isFocus CONSTANT)
|
Q_PROPERTY(bool focus READ isFocus CONSTANT)
|
||||||
Q_PROPERTY(int securityLevel READ getSecurityLevel NOTIFY securityLevelChanged)
|
Q_PROPERTY(int securityLevel READ getSecurityLevel NOTIFY securityLevelChanged)
|
||||||
|
|
@ -64,6 +64,8 @@ public:
|
||||||
int getDeviceCount() const;
|
int getDeviceCount() const;
|
||||||
|
|
||||||
bool isMe() const;
|
bool isMe() const;
|
||||||
|
void setIsMe(bool isMe);
|
||||||
|
void updateIsMe();
|
||||||
|
|
||||||
void setSipAddress(const QString &address);
|
void setSipAddress(const QString &address);
|
||||||
void setDisplayName(const QString &name);
|
void setDisplayName(const QString &name);
|
||||||
|
|
@ -85,6 +87,7 @@ signals:
|
||||||
void sipAddressChanged();
|
void sipAddressChanged();
|
||||||
void isAdminChanged();
|
void isAdminChanged();
|
||||||
void isFocusChanged();
|
void isFocusChanged();
|
||||||
|
void isMeChanged();
|
||||||
void deviceCountChanged();
|
void deviceCountChanged();
|
||||||
void invitingChanged();
|
void invitingChanged();
|
||||||
void creationTimeChanged();
|
void creationTimeChanged();
|
||||||
|
|
@ -109,6 +112,7 @@ private:
|
||||||
bool mAdminStatus;
|
bool mAdminStatus;
|
||||||
bool mIsFocus;
|
bool mIsFocus;
|
||||||
int mSecurityLevel;
|
int mSecurityLevel;
|
||||||
|
bool mIsMe;
|
||||||
|
|
||||||
DECLARE_ABSTRACT_OBJECT
|
DECLARE_ABSTRACT_OBJECT
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,9 @@ SafeObject::SafeObject(QVariant defaultValue, QObject *parent) : mValue(defaultV
|
||||||
}
|
}
|
||||||
SafeObject::~SafeObject() {
|
SafeObject::~SafeObject() {
|
||||||
}
|
}
|
||||||
|
void SafeObject::setDefaultValue(QVariant value) {
|
||||||
|
mValue = value;
|
||||||
|
}
|
||||||
QVariant SafeObject::getValue() const {
|
QVariant SafeObject::getValue() const {
|
||||||
return mValue;
|
return mValue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ public:
|
||||||
|
|
||||||
QVariant getValue() const;
|
QVariant getValue() const;
|
||||||
void onSetValue(QVariant value);
|
void onSetValue(QVariant value);
|
||||||
|
void setDefaultValue(QVariant value); // Don't send signal
|
||||||
signals:
|
signals:
|
||||||
void requestValue();
|
void requestValue();
|
||||||
void setValue(QVariant value);
|
void setValue(QVariant value);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,9 @@ VariantObject::~VariantObject() {
|
||||||
QVariant VariantObject::getValue() const {
|
QVariant VariantObject::getValue() const {
|
||||||
return mCoreObject->getValue();
|
return mCoreObject->getValue();
|
||||||
}
|
}
|
||||||
|
void VariantObject::setDefaultValue(QVariant value) {
|
||||||
|
mCoreObject->setDefaultValue(value);
|
||||||
|
}
|
||||||
void VariantObject::requestValue() {
|
void VariantObject::requestValue() {
|
||||||
emit mCoreObject->requestValue();
|
emit mCoreObject->requestValue();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ public:
|
||||||
|
|
||||||
QVariant getValue() const;
|
QVariant getValue() const;
|
||||||
void requestValue();
|
void requestValue();
|
||||||
|
void setDefaultValue(QVariant value);
|
||||||
|
|
||||||
QSharedPointer<SafeObject> mCoreObject, mModelObject;
|
QSharedPointer<SafeObject> mCoreObject, mModelObject;
|
||||||
QSharedPointer<SafeConnection<SafeObject, SafeObject>> mConnection;
|
QSharedPointer<SafeConnection<SafeObject, SafeObject>> mConnection;
|
||||||
|
|
|
||||||
|
|
@ -302,26 +302,32 @@ QString Utils::formatDateElapsedTime(const QDateTime &date) {
|
||||||
return QString::number(s) + " s";
|
return QString::number(s) + " s";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Utils::interpretUrl(const QString &uri) {
|
VariantObject *Utils::interpretUrl(QString uri) {
|
||||||
|
VariantObject *data = new VariantObject(uri);
|
||||||
|
if (!data) return nullptr;
|
||||||
|
data->makeRequest([uri]() -> QVariant {
|
||||||
QString address = uri;
|
QString address = uri;
|
||||||
|
|
||||||
if (!address.contains('@')) {
|
|
||||||
App::postModelBlock([&address, uri]() mutable {
|
|
||||||
auto addr = ToolModel::interpretUrl(uri);
|
auto addr = ToolModel::interpretUrl(uri);
|
||||||
if (addr) address = Utils::coreStringToAppString(addr->asStringUriOnly());
|
if (addr) address = Utils::coreStringToAppString(addr->asStringUriOnly());
|
||||||
|
return QVariant(address);
|
||||||
});
|
});
|
||||||
} else if (!address.startsWith("sip:")) {
|
if (!uri.contains('@')) {
|
||||||
address.prepend("sip:");
|
data->requestValue();
|
||||||
|
} else if (!uri.startsWith("sip:")) {
|
||||||
|
uri.prepend("sip:");
|
||||||
|
data->setDefaultValue(uri);
|
||||||
}
|
}
|
||||||
return address;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Utils::isValidSIPAddress(const QString &uri) {
|
VariantObject *Utils::isValidSIPAddress(QString uri) {
|
||||||
bool isValid = false;
|
VariantObject *data = new VariantObject(QVariant(false));
|
||||||
App::postModelBlock([&isValid, uri]() mutable {
|
if (!data) return nullptr;
|
||||||
isValid = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(uri)) != nullptr;
|
data->makeRequest([uri]() -> QVariant {
|
||||||
|
return QVariant(linphone::Factory::get()->createAddress(Utils::appStringToCoreString(uri)) != nullptr);
|
||||||
});
|
});
|
||||||
return isValid;
|
data->requestValue();
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Utils::isValidIPAddress(const QString &host) {
|
bool Utils::isValidIPAddress(const QString &host) {
|
||||||
|
|
@ -345,18 +351,20 @@ bool Utils::isValidURL(const QString &url) {
|
||||||
return QUrl(url).isValid();
|
return QUrl(url).isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Utils::findAvatarByAddress(const QString &address) {
|
VariantObject *Utils::findAvatarByAddress(const QString &address) {
|
||||||
|
VariantObject *data = new VariantObject("");
|
||||||
|
if (!data) return nullptr;
|
||||||
|
data->makeRequest([address]() -> QVariant {
|
||||||
QString avatar;
|
QString avatar;
|
||||||
|
|
||||||
App::postModelBlock([address, avatar]() mutable {
|
|
||||||
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
|
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
|
||||||
if (!defaultFriendList) return;
|
if (!defaultFriendList) return QVariant();
|
||||||
auto linphoneAddr = ToolModel::interpretUrl(address);
|
auto linphoneAddr = ToolModel::interpretUrl(address);
|
||||||
auto linFriend = CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
|
auto linFriend = CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
|
||||||
if (linFriend) avatar = Utils::coreStringToAppString(linFriend->getPhoto());
|
if (linFriend) avatar = Utils::coreStringToAppString(linFriend->getPhoto());
|
||||||
|
return QVariant(avatar);
|
||||||
});
|
});
|
||||||
|
data->requestValue();
|
||||||
return avatar;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
VariantObject *Utils::findFriendByAddress(const QString &address) {
|
VariantObject *Utils::findFriendByAddress(const QString &address) {
|
||||||
|
|
@ -1328,17 +1336,17 @@ int Utils::getYear(const QDate &date) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VariantObject *Utils::isMe(const QString &address) {
|
VariantObject *Utils::isMe(const QString &address) {
|
||||||
bool isMe = false;
|
VariantObject *data = new VariantObject(QVariant(false));
|
||||||
VariantObject *data = new VariantObject();
|
|
||||||
if (!data) return nullptr;
|
if (!data) return nullptr;
|
||||||
data->makeRequest([&isMe, address]() { return QVariant::fromValue(ToolModel::isMe(address)); });
|
data->makeRequest([address]() { return QVariant::fromValue(ToolModel::isMe(address)); });
|
||||||
data->requestValue();
|
data->requestValue();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
bool Utils::isLocal(const QString &address) {
|
VariantObject *Utils::isLocal(const QString &address) {
|
||||||
bool isLocal = false;
|
VariantObject *data = new VariantObject(QVariant(false));
|
||||||
App::postModelSync([&isLocal, address]() { isLocal = ToolModel::isLocal(address); });
|
data->makeRequest([address]() { return QVariant(ToolModel::isLocal(address)); });
|
||||||
return isLocal;
|
data->requestValue();
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Utils::isUsername(const QString &txt) {
|
bool Utils::isUsername(const QString &txt) {
|
||||||
|
|
|
||||||
|
|
@ -113,17 +113,17 @@ public:
|
||||||
Q_INVOKABLE static QDateTime addYears(QDateTime date, int years);
|
Q_INVOKABLE static QDateTime addYears(QDateTime date, int years);
|
||||||
Q_INVOKABLE static int timeOffset(QDateTime start, QDateTime end);
|
Q_INVOKABLE static int timeOffset(QDateTime start, QDateTime end);
|
||||||
Q_INVOKABLE static int daysOffset(QDateTime start, QDateTime end);
|
Q_INVOKABLE static int daysOffset(QDateTime start, QDateTime end);
|
||||||
Q_INVOKABLE static QString interpretUrl(const QString &uri);
|
Q_INVOKABLE static VariantObject *interpretUrl(QString uri);
|
||||||
Q_INVOKABLE static bool isValidSIPAddress(const QString &uri);
|
Q_INVOKABLE static VariantObject *isValidSIPAddress(QString uri);
|
||||||
Q_INVOKABLE static bool isValidIPAddress(const QString &host);
|
Q_INVOKABLE static bool isValidIPAddress(const QString &host);
|
||||||
Q_INVOKABLE static bool isValidHostname(const QString &hostname);
|
Q_INVOKABLE static bool isValidHostname(const QString &hostname);
|
||||||
Q_INVOKABLE static bool isValidURL(const QString &url);
|
Q_INVOKABLE static bool isValidURL(const QString &url);
|
||||||
Q_INVOKABLE static QString findAvatarByAddress(const QString &address);
|
Q_INVOKABLE static VariantObject *findAvatarByAddress(const QString &address);
|
||||||
Q_INVOKABLE static VariantObject *findFriendByAddress(const QString &address);
|
Q_INVOKABLE static VariantObject *findFriendByAddress(const QString &address);
|
||||||
Q_INVOKABLE static VariantObject *getFriendAddressSecurityLevel(const QString &address);
|
Q_INVOKABLE static VariantObject *getFriendAddressSecurityLevel(const QString &address);
|
||||||
static QString generateSavedFilename(const QString &from, const QString &to);
|
static QString generateSavedFilename(const QString &from, const QString &to);
|
||||||
Q_INVOKABLE static VariantObject *isMe(const QString &address);
|
Q_INVOKABLE static VariantObject *isMe(const QString &address);
|
||||||
Q_INVOKABLE static bool isLocal(const QString &address);
|
Q_INVOKABLE static VariantObject *isLocal(const QString &address);
|
||||||
Q_INVOKABLE static bool isUsername(const QString &txt); // Regex check
|
Q_INVOKABLE static bool isUsername(const QString &txt); // Regex check
|
||||||
static QString getCountryName(const QLocale::Territory &p_country);
|
static QString getCountryName(const QLocale::Territory &p_country);
|
||||||
Q_INVOKABLE static void useFetchConfig(const QString &configUrl);
|
Q_INVOKABLE static void useFetchConfig(const QString &configUrl);
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,8 @@ Loader{
|
||||||
property bool haveAvatar: (account && account.core?.pictureUri || false)
|
property bool haveAvatar: (account && account.core?.pictureUri || false)
|
||||||
|| (contact && contact.core.pictureUri)
|
|| (contact && contact.core.pictureUri)
|
||||||
|| computedAvatarUri.length != 0
|
|| computedAvatarUri.length != 0
|
||||||
property string computedAvatarUri: UtilsCpp.findAvatarByAddress(_address)
|
property var avatarObj: UtilsCpp.findAvatarByAddress(_address)
|
||||||
|
property string computedAvatarUri: avatarObj ? avatarObj.value : ''
|
||||||
onHaveAvatarChanged: replace(haveAvatar ? avatar : initials, StackView.Immediate)
|
|
||||||
|
|
||||||
property var securityLevelObj: UtilsCpp.getFriendAddressSecurityLevel(_address)
|
property var securityLevelObj: UtilsCpp.getFriendAddressSecurityLevel(_address)
|
||||||
property var securityLevel: securityLevelObj ? securityLevelObj.value : LinphoneEnums.SecurityLevel.None
|
property var securityLevel: securityLevelObj ? securityLevelObj.value : LinphoneEnums.SecurityLevel.None
|
||||||
|
|
@ -69,8 +68,14 @@ Loader{
|
||||||
StackView {
|
StackView {
|
||||||
id: stackView
|
id: stackView
|
||||||
|
|
||||||
initialItem: haveAvatar ? avatar : initials
|
initialItem: mainItem.haveAvatar ? avatar : initials
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Connections{
|
||||||
|
target: mainItem
|
||||||
|
onHaveAvatarChanged: function(haveAvatar) {stackView.replace(haveAvatar ? avatar : initials, StackView.Immediate)}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: mainItem.secured || mainItem.securityBreach
|
visible: mainItem.secured || mainItem.securityBreach
|
||||||
anchors.fill: stackView.currentItem
|
anchors.fill: stackView.currentItem
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,8 @@ Item {
|
||||||
_address: magicSearchBar.text
|
_address: magicSearchBar.text
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
text: UtilsCpp.interpretUrl(magicSearchBar.text)
|
property var urlObj: UtilsCpp.interpretUrl(magicSearchBar.text)
|
||||||
|
text: urlObj?.value
|
||||||
font {
|
font {
|
||||||
pixelSize: 12 * DefaultStyle.dp
|
pixelSize: 12 * DefaultStyle.dp
|
||||||
weight: 300 * DefaultStyle.dp
|
weight: 300 * DefaultStyle.dp
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,6 @@ AbstractMainPage {
|
||||||
Binding on text {
|
Binding on text {
|
||||||
when: searchBar.text.length !== 0
|
when: searchBar.text.length !== 0
|
||||||
value: qsTr("Aucun appel correspondant")
|
value: qsTr("Aucun appel correspondant")
|
||||||
restoreMode: Binding.RestoreBindingOrValue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ListView {
|
ListView {
|
||||||
|
|
@ -497,7 +496,7 @@ AbstractMainPage {
|
||||||
}
|
}
|
||||||
Connections {
|
Connections {
|
||||||
target: mainItem
|
target: mainItem
|
||||||
function onCreateCallFromSearchBarRequested(){ UtilsCpp.createCall(UtilsCpp.interpretUrl(callContactsList.searchBar.text))}
|
function onCreateCallFromSearchBarRequested(){ UtilsCpp.createCall(callContactsList.searchBar.text)}
|
||||||
function onOpenNumPadRequest(){ if (!callContactsList.searchBar.numericPadButton.checked) callContactsList.searchBar.numericPadButton.checked = true}
|
function onOpenNumPadRequest(){ if (!callContactsList.searchBar.numericPadButton.checked) callContactsList.searchBar.numericPadButton.checked = true}
|
||||||
}
|
}
|
||||||
Binding {
|
Binding {
|
||||||
|
|
@ -505,7 +504,6 @@ AbstractMainPage {
|
||||||
property: "visible"
|
property: "visible"
|
||||||
value: true
|
value: true
|
||||||
when: callContactsList.searchBar.numericPadButton.checked
|
when: callContactsList.searchBar.numericPadButton.checked
|
||||||
restoreMode: Binding.RestoreValue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -253,10 +253,11 @@ ApplicationWindow {
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
height: 50
|
height: 50
|
||||||
width: 120
|
width: fpsText.implicitWidth
|
||||||
z: 100
|
z: 100
|
||||||
visible: !SettingsCpp.hideFps
|
visible: !SettingsCpp.hideFps
|
||||||
Text{
|
Text{
|
||||||
|
id: fpsText
|
||||||
font.bold: true
|
font.bold: true
|
||||||
font.italic: true
|
font.italic: true
|
||||||
font.pixelSize: 14 * DefaultStyle.dp
|
font.pixelSize: 14 * DefaultStyle.dp
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue