From 49f5f63e58e2ec38c7ecaff587f1c575baa12084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Mon, 3 Aug 2020 10:36:44 -0400 Subject: [PATCH] api: follow daemon changes on accountAvatarReceived (breaking change) Change-Id: I78a515e6135eb68e85fe14a52c9f64795511e5c9 --- src/callbackshandler.cpp | 11 ++++++----- src/callbackshandler.h | 8 +++++--- src/newaccountmodel.cpp | 19 ++++++++++++++----- src/qtwrapper/configurationmanager_wrap.h | 8 ++++---- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/callbackshandler.cpp b/src/callbackshandler.cpp index 3c1c62a0..a5b20eff 100644 --- a/src/callbackshandler.cpp +++ b/src/callbackshandler.cpp @@ -182,9 +182,9 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent) Qt::QueuedConnection); connect(&ConfigurationManager::instance(), - &ConfigurationManagerInterface::accountAvatarReceived, + &ConfigurationManagerInterface::accountProfileReceived, this, - &CallbacksHandler::slotAccountAvatarReceived, + &CallbacksHandler::slotAccountProfileReceived, Qt::QueuedConnection); connect(&ConfigurationManager::instance(), @@ -498,10 +498,11 @@ CallbacksHandler::slotDeviceRevokationEnded(const QString& accountId, } void -CallbacksHandler::slotAccountAvatarReceived(const QString& accountId, - const QString& userPhoto) +CallbacksHandler::slotAccountProfileReceived(const QString& accountId, + const QString& displayName, + const QString& userPhoto) { - emit accountAvatarReceived(accountId, userPhoto); + emit accountProfileReceived(accountId, displayName, userPhoto); } void diff --git a/src/callbackshandler.h b/src/callbackshandler.h index 116adde2..0b0d5687 100644 --- a/src/callbackshandler.h +++ b/src/callbackshandler.h @@ -209,11 +209,12 @@ Q_SIGNALS: const int status); /** - * Account avatar has been received + * Account profile has been received * @param accountId + * @param displayName * @param userPhoto */ - void accountAvatarReceived(const QString& accountId, const QString& userPhoto); + void accountProfileReceived(const QString& accountId, const QString& displayName, const QString& userPhoto); /** * Emit exportOnRingEnded @@ -446,9 +447,10 @@ private Q_SLOTS: /** * Emit account avatar has been received * @param accountId + * @param displayName * @param userPhoto */ - void slotAccountAvatarReceived(const QString& accountId, const QString& userPhoto); + void slotAccountProfileReceived(const QString& accountId, const QString& displayName, const QString& userPhoto); /** * Emit exportOnRingEnded diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index 43bb45e3..c511a844 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -163,11 +163,12 @@ public Q_SLOTS: void slotMigrationEnded(const QString& accountId, bool ok); /** - * Emit accountAvatarReceived + * Emit accountProfileReceived * @param accountId + * @param displayName * @param userPhoto */ - void slotAccountAvatarReceived(const QString& accountId, const QString& userPhoto); + void slotAccountProfileReceived(const QString& accountId, const QString& displayName, const QString& userPhoto); }; NewAccountModel::NewAccountModel(Lrc& lrc, @@ -393,7 +394,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); + connect(&callbacksHandler, &CallbacksHandler::accountProfileReceived, this, &NewAccountModelPimpl::slotAccountProfileReceived); } NewAccountModelPimpl::~NewAccountModelPimpl() @@ -638,9 +639,17 @@ NewAccountModelPimpl::slotMigrationEnded(const QString& accountId, bool ok) } void -NewAccountModelPimpl::slotAccountAvatarReceived(const QString& accountId, const QString& userPhoto) +NewAccountModelPimpl::slotAccountProfileReceived(const QString& accountId, const QString& displayName, const QString& userPhoto) { - linked.setAvatar(accountId, userPhoto); + auto account = accounts.find(accountId); + if (account == accounts.end()) return; + auto& accountInfo = account->second.first; + accountInfo.profileInfo.avatar = userPhoto; + accountInfo.profileInfo.alias = displayName; + + authority::storage::createOrUpdateProfile(accountInfo.id, accountInfo.profileInfo); + + emit linked.profileUpdated(accountId); } void diff --git a/src/qtwrapper/configurationmanager_wrap.h b/src/qtwrapper/configurationmanager_wrap.h index c8b85512..3d273046 100644 --- a/src/qtwrapper/configurationmanager_wrap.h +++ b/src/qtwrapper/configurationmanager_wrap.h @@ -127,9 +127,9 @@ public: [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::AccountProfileReceived>( + [this](const std::string& accountId, const std::string& displayName, const std::string& userPhoto) { + Q_EMIT this->accountProfileReceived(QString(accountId.c_str()), QString(displayName.c_str()), QString(userPhoto.c_str())); }), exportable_callback<ConfigurationSignal::ExportOnRingEnded>( [this] (const std::string &accountId, int status, const std::string &pin) { @@ -755,7 +755,7 @@ Q_SIGNALS: // SIGNALS void profileReceived(const QString &accountID, const QString &peer, const QString &vCard); 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 accountProfileReceived(const QString& accountId, const QString& displayName, const QString& userPhoto); void debugMessageReceived(const QString& message); void composingStatusChanged(const QString& accountId, const QString& contactId, bool isComposing); }; -- GitLab