-
Notifications
You must be signed in to change notification settings - Fork 667
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sharing] Show placeholders for avatars Just like on the web show placeholders for avatars in the sharing dialog [Sharing] Show avatars! [Sharing] Show same avatar placeholder for group/federated shares as on web
- Loading branch information
Showing
6 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) by Roeland Jago Douma <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#include "avatarjob.h" | ||
#include "networkjobs.h" | ||
#include "account.h" | ||
|
||
#include <QLatin1String> | ||
|
||
namespace OCC { | ||
|
||
AvatarJob2::AvatarJob2(const QString &userId, int size, AccountPtr account, QObject* parent) | ||
: AbstractNetworkJob(account, QLatin1String("remote.php/dav/avatars/"), parent) | ||
{ | ||
setIgnoreCredentialFailure(true); | ||
|
||
//Append <userid>/<size> to the path | ||
setPath(path() + userId + QString("/%1").arg(size)); | ||
} | ||
|
||
void AvatarJob2::start() | ||
{ | ||
sendRequest("GET", Utility::concatUrlPath(account()->url(), path())); | ||
AbstractNetworkJob::start(); | ||
} | ||
|
||
bool AvatarJob2::finished() | ||
{ | ||
int statusCode = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); | ||
|
||
if (statusCode != 200) { | ||
emit avatarNotAvailable(statusCode); | ||
} else { | ||
QByteArray data = reply()->readAll(); | ||
QString mimeType = reply()->header(QNetworkRequest::ContentTypeHeader).toString(); | ||
emit avatarReady(data, mimeType); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (C) by Roeland Jago Douma <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#ifndef AVATARJOB_H | ||
#define AVATARJOB_H | ||
|
||
#include "networkjobs.h" | ||
#include "accountfwd.h" | ||
|
||
namespace OCC { | ||
|
||
/** | ||
* @brief Job to fetch an avatar for a user | ||
* @ingroup gui | ||
*/ | ||
class AvatarJob2 : public AbstractNetworkJob { | ||
Q_OBJECT | ||
public: | ||
/** | ||
* @param userId The user for which to obtain the avatar | ||
* @param size The size of the avatar (square so size*size) | ||
* @param account For which account to obtain the avatar | ||
* @param parent Parent of the object | ||
*/ | ||
explicit AvatarJob2(const QString& userId, int size, AccountPtr account, QObject* parent = 0); | ||
|
||
public slots: | ||
/* Start the job */ | ||
void start() Q_DECL_OVERRIDE; | ||
signals: | ||
/** | ||
* Signal that the job is done and returned an avatar | ||
* | ||
* @param reply the content of the reply | ||
* @param the mimetype (set by the server) | ||
*/ | ||
void avatarReady(QByteArray reply, QString mimeType); | ||
|
||
/** | ||
* Signal that the job is done but the server did not return | ||
* an avatar | ||
* | ||
* @param statusCode The status code returned by the server | ||
*/ | ||
void avatarNotAvailable(int statusCode); | ||
|
||
private slots: | ||
virtual bool finished() Q_DECL_OVERRIDE; | ||
}; | ||
|
||
} | ||
|
||
#endif // AVATAR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters