diff --git a/src/callbackshandler.cpp b/src/callbackshandler.cpp index dbcc80131b5993837f72b8afaaa30e42f09a0cd7..8036d40a5d93d882604befab4d1d827d102c6e8f 100644 --- a/src/callbackshandler.cpp +++ b/src/callbackshandler.cpp @@ -181,6 +181,12 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent) &CallbacksHandler::slotDeviceRevokationEnded, Qt::QueuedConnection); + connect(&ConfigurationManager::instance(), + &ConfigurationManagerInterface::accountAvatarReceived, + this, + &CallbacksHandler::slotAccountAvatarReceived, + Qt::QueuedConnection); + connect(&ConfigurationManager::instance(), &ConfigurationManagerInterface::exportOnRingEnded, this, @@ -491,6 +497,13 @@ CallbacksHandler::slotDeviceRevokationEnded(const QString& accountId, emit deviceRevocationEnded(accountId, deviceId, status); } +void +CallbacksHandler::slotAccountAvatarReceived(const QString& accountId, + const QString& userPhoto) +{ + emit accountAvatarReceived(accountId, userPhoto); +} + void CallbacksHandler::slotExportOnRingEnded(const QString& accountId, int status, const QString& pin) { diff --git a/src/callbackshandler.h b/src/callbackshandler.h index 13bac0d288dfdc8083717fe05e4b50731f83bfbb..116adde22649d01008f6e8fcf1b2639d0f0a09e4 100644 --- a/src/callbackshandler.h +++ b/src/callbackshandler.h @@ -208,6 +208,13 @@ Q_SIGNALS: const QString& deviceId, const int status); + /** + * Account avatar has been received + * @param accountId + * @param userPhoto + */ + void accountAvatarReceived(const QString& accountId, const QString& userPhoto); + /** * Emit exportOnRingEnded * @param accountId @@ -436,6 +443,13 @@ private Q_SLOTS: const QString& deviceId, const int status); + /** + * Emit account avatar has been received + * @param accountId + * @param userPhoto + */ + void slotAccountAvatarReceived(const QString& accountId, const QString& userPhoto); + /** * Emit exportOnRingEnded * @param accountId diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index da519930b6f6263f0d9dc44b89019b2f9bdd6769..9b16fa3f66bea20acf8485f57f82bceb0698498e 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -155,6 +155,13 @@ public Q_SLOTS: * @param ok */ void slotMigrationEnded(const QString& accountId, bool ok); + + /** + * Emit accountAvatarReceived + * @param accountId + * @param userPhoto + */ + void slotAccountAvatarReceived(const QString& accountId, const QString& userPhoto); }; NewAccountModel::NewAccountModel(Lrc& lrc, @@ -380,6 +387,7 @@ NewAccountModelPimpl::NewAccountModelPimpl(NewAccountModel& linked, connect(&callbacksHandler, &CallbacksHandler::nameRegistrationEnded, this, &NewAccountModelPimpl::slotNameRegistrationEnded); connect(&callbacksHandler, &CallbacksHandler::registeredNameFound, this, &NewAccountModelPimpl::slotRegisteredNameFound); connect(&callbacksHandler, &CallbacksHandler::migrationEnded, this, &NewAccountModelPimpl::slotMigrationEnded); + connect(&callbacksHandler, &CallbacksHandler::accountAvatarReceived, this, &NewAccountModelPimpl::slotAccountAvatarReceived); } NewAccountModelPimpl::~NewAccountModelPimpl() @@ -597,6 +605,12 @@ NewAccountModelPimpl::slotMigrationEnded(const QString& accountId, bool ok) emit linked.migrationEnded(accountId, ok); } +void +NewAccountModelPimpl::slotAccountAvatarReceived(const QString& accountId, const QString& userPhoto) +{ + linked.setAvatar(accountId, userPhoto); +} + void NewAccountModelPimpl::addToAccounts(const QString& accountId, std::shared_ptr<Database> db) diff --git a/src/qtwrapper/configurationmanager_wrap.h b/src/qtwrapper/configurationmanager_wrap.h index 009aab1e1ef9e06d9f3507cba7aa3205993c224f..4b3ec52322cd7753048cb9fc58bec421600ec12f 100644 --- a/src/qtwrapper/configurationmanager_wrap.h +++ b/src/qtwrapper/configurationmanager_wrap.h @@ -126,7 +126,11 @@ public: exportable_callback<ConfigurationSignal::DeviceRevocationEnded>( [this] (const std::string &accountId, const std::string &device, int status) { Q_EMIT this->deviceRevocationEnded(QString(accountId.c_str()), QString(device.c_str()), status); - }), + }), + exportable_callback<ConfigurationSignal::AccountAvatarReceived>( + [this](const std::string& accountId, const std::string& userPhoto) { + Q_EMIT this->accountAvatarReceived(QString(accountId.c_str()), QString(userPhoto.c_str())); + }), exportable_callback<ConfigurationSignal::ExportOnRingEnded>( [this] (const std::string &accountId, int status, const std::string &pin) { Q_EMIT this->exportOnRingEnded(QString(accountId.c_str()), status, QString(pin.c_str())); @@ -742,6 +746,7 @@ Q_SIGNALS: // SIGNALS void contactRemoved(const QString &accountID, const QString &uri, bool banned); void dataTransferEvent(qulonglong transfer_id, uint code); void deviceRevocationEnded(const QString& accountId, const QString& deviceId, int status); + void accountAvatarReceived(const QString& accountId, const QString& userPhoto); void debugMessageReceived(const QString& message); void composingStatusChanged(const QString& accountId, const QString& contactId, bool isComposing); }; diff --git a/test/mocks/configurationmanager_mock.h b/test/mocks/configurationmanager_mock.h index 0dda58e3ba0f74a2228d6ef20958335064f7f665..4e2d79ca2aba1038a9b1a05c3de7adefdc4360e2 100644 --- a/test/mocks/configurationmanager_mock.h +++ b/test/mocks/configurationmanager_mock.h @@ -852,6 +852,7 @@ Q_SIGNALS: // SIGNALS void contactRemoved(const QString &accountId, const QString &uri, bool banned); void dataTransferEvent(uint64_t transfer_id, uint32_t code); void deviceRevocationEnded(const QString& accountId, const QString& deviceId, int status); + void avatarReceived(const QString& accountId, const QString& userPhoto); void debugMessageReceived(const std::string& message); };