mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-23 08:13:51 +02:00
update-profile: moved to new API for setting Avatar
This change only impacts avatar updates; moving to the new API for updating the displayName is still pending and may require additional work. Specifically, we need to provide the current profile picture path to prevent its removal during the update process. Change-Id: Idbc1592eda2b533b633cc366c72224f5e1bdce98
This commit is contained in:
parent
04fca1fc75
commit
a01b578099
5 changed files with 37 additions and 16 deletions
2
daemon
2
daemon
|
@ -1 +1 @@
|
||||||
Subproject commit 57e91daefea5c3d8e3604c3cc2b6c1d2adbed0d5
|
Subproject commit 9c3465ba7c2dfe7d5c061bf4a4adab2ffdb2f5c1
|
|
@ -114,7 +114,7 @@ AccountAdapter::createJamiAccount(const QVariantMap& settings)
|
||||||
&lrcInstance_->accountModel(),
|
&lrcInstance_->accountModel(),
|
||||||
&lrc::api::AccountModel::accountAdded,
|
&lrc::api::AccountModel::accountAdded,
|
||||||
[this, registeredName, settings](const QString& accountId) {
|
[this, registeredName, settings](const QString& accountId) {
|
||||||
lrcInstance_->accountModel().setAvatar(accountId, settings["avatar"].toString());
|
lrcInstance_->accountModel().setAvatar(accountId, settings["avatar"].toString(), true,1);
|
||||||
Utils::oneShotConnect(&lrcInstance_->accountModel(),
|
Utils::oneShotConnect(&lrcInstance_->accountModel(),
|
||||||
&lrc::api::AccountModel::accountDetailsChanged,
|
&lrc::api::AccountModel::accountDetailsChanged,
|
||||||
[this](const QString& accountId) {
|
[this](const QString& accountId) {
|
||||||
|
@ -303,13 +303,8 @@ AccountAdapter::setCurrentAccountAvatarFile(const QString& source)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ba;
|
|
||||||
QBuffer bu(&ba);
|
|
||||||
bu.open(QIODevice::WriteOnly);
|
|
||||||
image.save(&bu, "PNG");
|
|
||||||
auto str = QString::fromLocal8Bit(ba.toBase64());
|
|
||||||
auto accountId = lrcInstance_->get_currentAccountId();
|
auto accountId = lrcInstance_->get_currentAccountId();
|
||||||
lrcInstance_->accountModel().setAvatar(accountId, str);
|
lrcInstance_->accountModel().setAvatar(accountId, source);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +313,7 @@ AccountAdapter::setCurrentAccountAvatarBase64(const QString& data)
|
||||||
{
|
{
|
||||||
auto futureResult = QtConcurrent::run([this, data]() {
|
auto futureResult = QtConcurrent::run([this, data]() {
|
||||||
auto accountId = lrcInstance_->get_currentAccountId();
|
auto accountId = lrcInstance_->get_currentAccountId();
|
||||||
lrcInstance_->accountModel().setAvatar(accountId, data);
|
lrcInstance_->accountModel().setAvatar(accountId, data, true, 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,20 +284,25 @@ AccountModel::setAlias(const QString& accountId, const QString& alias, bool save
|
||||||
accountInfo.profileInfo.alias = alias;
|
accountInfo.profileInfo.alias = alias;
|
||||||
|
|
||||||
if (save)
|
if (save)
|
||||||
storage::vcard::setProfile(accountInfo.id, accountInfo.profileInfo);
|
ConfigurationManager::instance().updateProfile(accountId,
|
||||||
|
alias,
|
||||||
|
"",
|
||||||
|
5);// flag out of range to avoid updating avatar
|
||||||
Q_EMIT profileUpdated(accountId);
|
Q_EMIT profileUpdated(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AccountModel::setAvatar(const QString& accountId, const QString& avatar, bool save)
|
AccountModel::setAvatar(const QString& accountId, const QString& avatar, bool save, int flag)
|
||||||
{
|
{
|
||||||
auto& accountInfo = pimpl_->getAccountInfo(accountId);
|
auto& accountInfo = pimpl_->getAccountInfo(accountId);
|
||||||
if (accountInfo.profileInfo.avatar == avatar)
|
if (accountInfo.profileInfo.avatar == avatar)
|
||||||
return;
|
return;
|
||||||
accountInfo.profileInfo.avatar = avatar;
|
accountInfo.profileInfo.avatar = avatar;
|
||||||
|
|
||||||
if (save)
|
if (save)
|
||||||
storage::vcard::setProfile(accountInfo.id, accountInfo.profileInfo);
|
ConfigurationManager::instance().updateProfile(accountId,
|
||||||
|
accountInfo.profileInfo.alias,
|
||||||
|
avatar,
|
||||||
|
flag);
|
||||||
Q_EMIT profileUpdated(accountId);
|
Q_EMIT profileUpdated(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ public:
|
||||||
* @param avatar
|
* @param avatar
|
||||||
* @throws out_of_range exception if account is not found
|
* @throws out_of_range exception if account is not found
|
||||||
*/
|
*/
|
||||||
void setAvatar(const QString& accountId, const QString& avatar, bool save = true);
|
void setAvatar(const QString& accountId, const QString& avatar, bool save = true, int flag =0);
|
||||||
/**
|
/**
|
||||||
* Change the alias of an account
|
* Change the alias of an account
|
||||||
* @param accountId
|
* @param accountId
|
||||||
|
|
|
@ -469,7 +469,10 @@ public Q_SLOTS: // METHODS
|
||||||
address.toStdString());
|
address.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool registerName(const QString& accountId, const QString& name, const QString& scheme, const QString& password)
|
bool registerName(const QString& accountId,
|
||||||
|
const QString& name,
|
||||||
|
const QString& scheme,
|
||||||
|
const QString& password)
|
||||||
{
|
{
|
||||||
return libjami::registerName(accountId.toStdString(),
|
return libjami::registerName(accountId.toStdString(),
|
||||||
name.toStdString(),
|
name.toStdString(),
|
||||||
|
@ -483,6 +486,21 @@ public Q_SLOTS: // METHODS
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateProfile(const QString& accountId,
|
||||||
|
const QString& displayName,
|
||||||
|
const QString& avatarPath,
|
||||||
|
int flag)
|
||||||
|
{
|
||||||
|
// file type is set to PNG by default
|
||||||
|
// it can be changed to JPEG to optimize compression
|
||||||
|
libjami::updateProfile(accountId.toStdString(),
|
||||||
|
displayName.toStdString(),
|
||||||
|
avatarPath.toStdString(),
|
||||||
|
"PNG",
|
||||||
|
flag
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList getAccountList()
|
QStringList getAccountList()
|
||||||
{
|
{
|
||||||
return convertStringList(libjami::getAccountList());
|
return convertStringList(libjami::getAccountList());
|
||||||
|
@ -835,7 +853,10 @@ public Q_SLOTS: // METHODS
|
||||||
libjami::removeContact(accountId.toStdString(), uri.toStdString(), ban);
|
libjami::removeContact(accountId.toStdString(), uri.toStdString(), ban);
|
||||||
}
|
}
|
||||||
|
|
||||||
void revokeDevice(const QString& accountId, const QString& deviceId, const QString& scheme, const QString& password)
|
void revokeDevice(const QString& accountId,
|
||||||
|
const QString& deviceId,
|
||||||
|
const QString& scheme,
|
||||||
|
const QString& password)
|
||||||
{
|
{
|
||||||
libjami::revokeDevice(accountId.toStdString(),
|
libjami::revokeDevice(accountId.toStdString(),
|
||||||
deviceId.toStdString(),
|
deviceId.toStdString(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue