From abf310df34811afb7e2a300ed57f9ff6fb5a8212 Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Wed, 29 Jan 2020 17:29:56 -0500 Subject: [PATCH] accounts: handle account avatar signal from daemon Change-Id: I50bfa8796dd0d4158527af404a20a597e2f8de26 --- src/callbackshandler.cpp | 13 +++++++++++++ src/callbackshandler.h | 14 ++++++++++++++ src/newaccountmodel.cpp | 14 ++++++++++++++ src/qtwrapper/configurationmanager_wrap.h | 7 ++++++- test/mocks/configurationmanager_mock.h | 1 + 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/callbackshandler.cpp b/src/callbackshandler.cpp index dbcc8013..8036d40a 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 13bac0d2..116adde2 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 da519930..9b16fa3f 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 009aab1e..4b3ec523 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 0dda58e3..4e2d79ca 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); }; -- GitLab