diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 77f953659..ad4ca60f4 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -90,6 +90,16 @@ void Account::setDavUser(const QString &newDavUser) _davUser = newDavUser; } +QPixmap Account::avatar() const +{ + return _avatarPixmap; +} +void Account::setAvatar(const QPixmap& pixmap) +{ + _avatarPixmap = pixmap; + emit accountChangedAvatar(); +} + QString Account::displayName() const { QString dn = QString("%1@%2").arg(_credentials->user(), _url.host()); diff --git a/src/libsync/account.h b/src/libsync/account.h index 2c21fa548..a4894a6e9 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -26,6 +26,8 @@ #include #include #include +#include + #include "utility.h" #include #include "capabilities.h" @@ -78,6 +80,9 @@ public: QString davUser() const; void setDavUser(const QString &newDavUser); + QPixmap avatar() const; + void setAvatar(const QPixmap& pixmap); + /// The name of the account as shown in the toolbar QString displayName() const; @@ -197,6 +202,8 @@ signals: void serverVersionChanged(Account* account, const QString& newVersion, const QString& oldVersion); + void accountChangedAvatar(); + protected Q_SLOTS: void slotHandleSslErrors(QNetworkReply*,QList); void slotCredentialsFetched(); @@ -209,6 +216,7 @@ private: QWeakPointer _sharedThis; QString _id; QString _davUser; + QPixmap _avatarPixmap; QMap _settingsMap; QUrl _url; QList _approvedCerts; diff --git a/src/libsync/connectionvalidator.cpp b/src/libsync/connectionvalidator.cpp index ec63685aa..d1c40d768 100644 --- a/src/libsync/connectionvalidator.cpp +++ b/src/libsync/connectionvalidator.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "connectionvalidator.h" #include "account.h" @@ -252,7 +253,17 @@ void ConnectionValidator::slotUserFetched(const QVariantMap &json) QString user = json.value("ocs").toMap().value("data").toMap().value("id").toString(); if (!user.isEmpty()) { _account->setDavUser(user); + + AvatarJob *job = new AvatarJob(_account, this); + QObject::connect(job, SIGNAL(avatarPixmap(QPixmap)), this, SLOT(slotAvatarPixmap(QPixmap))); + + job->start(); } +} + +void ConnectionValidator::slotAvatarPixmap(const QPixmap& pixmap) +{ + _account->setAvatar(pixmap); reportResult(Connected); } diff --git a/src/libsync/connectionvalidator.h b/src/libsync/connectionvalidator.h index 13e1435a5..e4f0fac7f 100644 --- a/src/libsync/connectionvalidator.h +++ b/src/libsync/connectionvalidator.h @@ -119,6 +119,7 @@ protected slots: void slotCapabilitiesRecieved(const QVariantMap&); void slotUserFetched(const QVariantMap &); + void slotAvatarPixmap(const QPixmap&); private: void reportResult(Status status);