diff --git a/daemon b/daemon index 57e91daefea5c3d8e3604c3cc2b6c1d2adbed0d5..9c3465ba7c2dfe7d5c061bf4a4adab2ffdb2f5c1 160000 --- a/daemon +++ b/daemon @@ -1 +1 @@ -Subproject commit 57e91daefea5c3d8e3604c3cc2b6c1d2adbed0d5 +Subproject commit 9c3465ba7c2dfe7d5c061bf4a4adab2ffdb2f5c1 diff --git a/src/app/accountadapter.cpp b/src/app/accountadapter.cpp index 95d7d730fb5ad5f596d354d4ffe9cb7fd8de3f02..3f687dfe76c7656a4c4b960e2950bb0418b093b7 100644 --- a/src/app/accountadapter.cpp +++ b/src/app/accountadapter.cpp @@ -114,7 +114,7 @@ AccountAdapter::createJamiAccount(const QVariantMap& settings) &lrcInstance_->accountModel(), &lrc::api::AccountModel::accountAdded, [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(), &lrc::api::AccountModel::accountDetailsChanged, [this](const QString& accountId) { @@ -303,13 +303,8 @@ AccountAdapter::setCurrentAccountAvatarFile(const QString& source) 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(); - 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 accountId = lrcInstance_->get_currentAccountId(); - lrcInstance_->accountModel().setAvatar(accountId, data); + lrcInstance_->accountModel().setAvatar(accountId, data, true, 1); }); } diff --git a/src/libclient/accountmodel.cpp b/src/libclient/accountmodel.cpp index 07af96f4c6fbfdd471cc8fbdb6b7fa2fca0d5069..3483f67f25f59a136b17724c3e0c0df616117433 100644 --- a/src/libclient/accountmodel.cpp +++ b/src/libclient/accountmodel.cpp @@ -284,20 +284,25 @@ AccountModel::setAlias(const QString& accountId, const QString& alias, bool save accountInfo.profileInfo.alias = alias; 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); } 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); if (accountInfo.profileInfo.avatar == avatar) return; accountInfo.profileInfo.avatar = avatar; - if (save) - storage::vcard::setProfile(accountInfo.id, accountInfo.profileInfo); + ConfigurationManager::instance().updateProfile(accountId, + accountInfo.profileInfo.alias, + avatar, + flag); Q_EMIT profileUpdated(accountId); } diff --git a/src/libclient/api/accountmodel.h b/src/libclient/api/accountmodel.h index ba58eddf2709b340e5ef25ce3339109ad5f5f424..e68b0cf8b578bd1c693609d76f5229fe0fb333ae 100644 --- a/src/libclient/api/accountmodel.h +++ b/src/libclient/api/accountmodel.h @@ -144,7 +144,7 @@ public: * @param avatar * @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 * @param accountId diff --git a/src/libclient/qtwrapper/configurationmanager_wrap.h b/src/libclient/qtwrapper/configurationmanager_wrap.h index 8692f0e3948679914ea2abff6420b6e973141eb8..157e05af676767257319b38ab5263ca384e98f75 100644 --- a/src/libclient/qtwrapper/configurationmanager_wrap.h +++ b/src/libclient/qtwrapper/configurationmanager_wrap.h @@ -469,7 +469,10 @@ public Q_SLOTS: // METHODS 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(), name.toStdString(), @@ -483,6 +486,21 @@ public Q_SLOTS: // METHODS 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() { return convertStringList(libjami::getAccountList()); @@ -835,7 +853,10 @@ public Q_SLOTS: // METHODS 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(), deviceId.toStdString(),