mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Store full address in friend and fix calling specific address from magic search (like conference)
This commit is contained in:
parent
390fc16c0a
commit
56b9d2c040
5 changed files with 38 additions and 15 deletions
|
|
@ -76,8 +76,9 @@ FriendCore::FriendCore(const std::shared_ptr<linphone::Friend> &contact, bool is
|
|||
mAddressList.append(
|
||||
createFriendAddressVariant(_addressLabel, Utils::coreStringToAppString(address->asStringUriOnly())));
|
||||
}
|
||||
mDefaultAddress =
|
||||
defaultAddress ? Utils::coreStringToAppString(contact->getAddress()->asStringUriOnly()) : QString();
|
||||
mDefaultAddress = defaultAddress ? Utils::coreStringToAppString(defaultAddress->asStringUriOnly()) : QString();
|
||||
mDefaultFullAddress = defaultAddress ? Utils::coreStringToAppString(defaultAddress->asString()) : QString();
|
||||
qWarning() << mDefaultAddress << " / " << mDefaultFullAddress;
|
||||
auto phoneNumbers = contact->getPhoneNumbersWithLabel();
|
||||
for (auto &phoneNumber : phoneNumbers) {
|
||||
mPhoneNumberList.append(
|
||||
|
|
@ -113,6 +114,7 @@ FriendCore::FriendCore(const FriendCore &friendCore) {
|
|||
mAddressList = friendCore.mAddressList;
|
||||
mPhoneNumberList = friendCore.mPhoneNumberList;
|
||||
mDefaultAddress = friendCore.mDefaultAddress;
|
||||
mDefaultFullAddress = friendCore.mDefaultFullAddress;
|
||||
mGivenName = friendCore.mGivenName;
|
||||
mFamilyName = friendCore.mFamilyName;
|
||||
mFullName = friendCore.mFullName;
|
||||
|
|
@ -240,6 +242,7 @@ void FriendCore::reset(const FriendCore &contact) {
|
|||
resetAddresses(contact.getAddresses());
|
||||
resetPhoneNumbers(contact.getPhoneNumbers());
|
||||
setDefaultAddress(contact.getDefaultAddress());
|
||||
setDefaultFullAddress(contact.getDefaultFullAddress());
|
||||
setGivenName(contact.getGivenName());
|
||||
setFamilyName(contact.getFamilyName());
|
||||
setOrganization(contact.getOrganization());
|
||||
|
|
@ -394,7 +397,7 @@ void FriendCore::setAddressAt(int index, QString label, QString address) {
|
|||
void FriendCore::removeAddress(int index) {
|
||||
if (index < 0 && index >= mAddressList.size()) return;
|
||||
auto map = mAddressList[index].toMap();
|
||||
if (map["address"].toString() == mDefaultAddress) mDefaultAddress.clear();
|
||||
if (map["address"].toString() == mDefaultFullAddress) mDefaultFullAddress.clear();
|
||||
mAddressList.remove(index);
|
||||
emit addressChanged();
|
||||
}
|
||||
|
|
@ -408,7 +411,7 @@ void FriendCore::appendAddress(const QString &addr) {
|
|||
if (interpretedAddress.isEmpty()) Utils::showInformationPopup(tr("Erreur"), tr("Adresse invalide"), false);
|
||||
else {
|
||||
mAddressList.append(createFriendAddressVariant(_addressLabel, interpretedAddress));
|
||||
if (mDefaultAddress.isEmpty()) mDefaultAddress = interpretedAddress;
|
||||
if (mDefaultFullAddress.isEmpty()) mDefaultFullAddress = interpretedAddress;
|
||||
emit addressChanged();
|
||||
}
|
||||
});
|
||||
|
|
@ -455,14 +458,25 @@ LinphoneEnums::SecurityLevel FriendCore::getSecurityLevelForAddress(const QStrin
|
|||
return LinphoneEnums::SecurityLevel::None;
|
||||
}
|
||||
|
||||
QString FriendCore::getDefaultFullAddress() const {
|
||||
return mDefaultFullAddress;
|
||||
}
|
||||
|
||||
void FriendCore::setDefaultFullAddress(const QString &address) {
|
||||
auto it = std::find_if(mAddressList.begin(), mAddressList.end(),
|
||||
[address](const QVariant &a) { return a.toMap()["address"].toString() == address; });
|
||||
if (it == mAddressList.end()) appendAddress(address);
|
||||
if (mDefaultFullAddress != address) {
|
||||
mDefaultFullAddress = address;
|
||||
emit defaultFullAddressChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString FriendCore::getDefaultAddress() const {
|
||||
return mDefaultAddress;
|
||||
}
|
||||
|
||||
void FriendCore::setDefaultAddress(const QString &address) {
|
||||
auto it = std::find_if(mAddressList.begin(), mAddressList.end(),
|
||||
[address](const QVariant &a) { return a.toMap()["address"].toString() == address; });
|
||||
if (it == mAddressList.end()) appendAddress(address);
|
||||
if (mDefaultAddress != address) {
|
||||
mDefaultAddress = address;
|
||||
emit defaultAddressChanged();
|
||||
|
|
@ -547,7 +561,7 @@ void FriendCore::writeIntoModel(std::shared_ptr<FriendModel> model) const {
|
|||
}
|
||||
model->resetAddresses(addresses);
|
||||
|
||||
model->setAddress(ToolModel::interpretUrl(mDefaultAddress));
|
||||
model->setAddress(ToolModel::interpretUrl(mDefaultFullAddress));
|
||||
|
||||
std::list<std::shared_ptr<linphone::FriendPhoneNumber>> phones;
|
||||
for (auto &number : mPhoneNumberList) {
|
||||
|
|
@ -606,15 +620,15 @@ void FriendCore::save() { // Save Values to model
|
|||
mustBeInMainThread(getClassName() + "::save()");
|
||||
if (mAddressList.size() > 0) {
|
||||
auto it = std::find_if(mAddressList.begin(), mAddressList.end(), [this](const QVariant &a) {
|
||||
return a.toMap()["address"].toString() == mDefaultAddress;
|
||||
return a.toMap()["address"].toString() == mDefaultFullAddress;
|
||||
});
|
||||
if (it == mAddressList.end()) {
|
||||
mDefaultAddress = mAddressList[0].toMap()["address"].toString();
|
||||
emit defaultAddressChanged();
|
||||
mDefaultFullAddress = mAddressList[0].toMap()["address"].toString();
|
||||
emit defaultFullAddressChanged();
|
||||
}
|
||||
} else {
|
||||
mDefaultAddress = "";
|
||||
emit defaultAddressChanged();
|
||||
mDefaultFullAddress = "";
|
||||
emit defaultFullAddressChanged();
|
||||
}
|
||||
FriendCore *thisCopy = new FriendCore(*this); // Pointer to avoid multiple copies in lambdas
|
||||
if (mFriendModel) {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ class FriendCore : public QObject, public AbstractObject {
|
|||
Q_PROPERTY(QString organization READ getOrganization WRITE setOrganization NOTIFY organizationChanged)
|
||||
Q_PROPERTY(QString job READ getJob WRITE setJob NOTIFY jobChanged)
|
||||
Q_PROPERTY(QString defaultAddress READ getDefaultAddress WRITE setDefaultAddress NOTIFY defaultAddressChanged)
|
||||
Q_PROPERTY(QString defaultFullAddress READ getDefaultFullAddress WRITE setDefaultFullAddress NOTIFY
|
||||
defaultFullAddressChanged)
|
||||
Q_PROPERTY(QDateTime presenceTimestamp READ getPresenceTimestamp NOTIFY presenceTimestampChanged)
|
||||
Q_PROPERTY(LinphoneEnums::ConsolidatedPresence consolidatedPresence READ getConsolidatedPresence NOTIFY
|
||||
consolidatedPresenceChanged)
|
||||
|
|
@ -115,6 +117,8 @@ public:
|
|||
|
||||
void setDefaultAddress(const QString &address);
|
||||
QString getDefaultAddress() const;
|
||||
void setDefaultFullAddress(const QString &address);
|
||||
QString getDefaultFullAddress() const;
|
||||
|
||||
QList<QVariant> getAllAddresses() const;
|
||||
|
||||
|
|
@ -170,6 +174,7 @@ signals:
|
|||
void isStoredChanged();
|
||||
void removed(FriendCore *contact);
|
||||
void defaultAddressChanged();
|
||||
void defaultFullAddressChanged();
|
||||
void allAddressesChanged();
|
||||
void devicesChanged();
|
||||
void verifiedDevicesChanged();
|
||||
|
|
@ -191,7 +196,8 @@ protected:
|
|||
QList<QVariant> mAddressList;
|
||||
QList<QVariant> mDeviceList;
|
||||
int mVerifiedDeviceCount;
|
||||
QString mDefaultAddress;
|
||||
QString mDefaultAddress; // Uri only
|
||||
QString mDefaultFullAddress;
|
||||
QString mPictureUri;
|
||||
bool mIsSaved;
|
||||
bool mIsStored;
|
||||
|
|
|
|||
|
|
@ -112,6 +112,8 @@ void MagicSearchList::setSelf(QSharedPointer<MagicSearchList> me) {
|
|||
} else {
|
||||
contact->setGivenName(Utils::coreStringToAppString(address->getUsername()));
|
||||
}
|
||||
contact->setDefaultFullAddress(Utils::coreStringToAppString(
|
||||
address->asString())); // linphone Friend object remove specific address.
|
||||
contacts->append(contact);
|
||||
} else if (!it->getPhoneNumber().empty()) {
|
||||
linphoneFriend = CoreModel::getInstance()->getCore()->createFriend();
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ FocusScope {
|
|||
radius: 40 * DefaultStyle.dp
|
||||
color: DefaultStyle.main2_200
|
||||
}
|
||||
onClicked: UtilsCpp.createCall(searchResultItem.core.defaultAddress)
|
||||
onClicked: UtilsCpp.createCall(searchResultItem.core.defaultFullAddress)
|
||||
KeyNavigation.right: chatButton
|
||||
KeyNavigation.left: chatButton
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ AbstractMainPage {
|
|||
friendGui.core.givenName = UtilsCpp.getGivenNameFromFullName(name)
|
||||
friendGui.core.familyName = UtilsCpp.getFamilyNameFromFullName(name)
|
||||
friendGui.core.defaultAddress = address
|
||||
friendGui.core.defaultFullAddress = address
|
||||
if (!rightPanelStackView.currentItem || rightPanelStackView.currentItem.objectName != "contactEdition")
|
||||
rightPanelStackView.push(contactEdition, {"contact": friendGui, "title": qsTr("Nouveau contact"), "saveButtonText": qsTr("Créer")})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue