Gravatar

gravatarresolvurljob.h
1/*
2 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "gravatar_export.h"
10#include <QObject>
11#include <QPixmap>
12#include <QUrl>
13
14#include <memory>
15
16class QNetworkReply;
17class GravatarResolvUrlJobTest;
18namespace Gravatar
19{
20class GravatarResolvUrlJobPrivate;
21class Hash;
22
23/** Avartar lookup job. */
24class GRAVATAR_EXPORT GravatarResolvUrlJob : public QObject
25{
26 Q_OBJECT
27public:
28 explicit GravatarResolvUrlJob(QObject *parent = nullptr);
29 ~GravatarResolvUrlJob() override;
30
31 [[nodiscard]] bool canStart() const;
32 void start();
33
34 [[nodiscard]] QString email() const;
35 void setEmail(const QString &email);
36
37 [[nodiscard]] bool hasGravatar() const;
38
39 void setSize(int size);
40 [[nodiscard]] int size() const;
41
42 [[nodiscard]] QPixmap pixmap() const;
43
44 [[nodiscard]] bool useDefaultPixmap() const;
45 void setUseDefaultPixmap(bool useDefaultPixmap);
46
47 bool useLibravatar() const;
48 void setUseLibravatar(bool useLibravatar);
49
50 bool fallbackGravatar() const;
51 void setFallbackGravatar(bool fallbackGravatar);
52
53Q_SIGNALS:
54 void finished(Gravatar::GravatarResolvUrlJob *);
55 void resolvUrl(const QUrl &url);
56
57private:
58 friend class ::GravatarResolvUrlJobTest;
59
60 void slotFinishLoadPixmap(QNetworkReply *reply);
61 [[nodiscard]] QUrl generateGravatarUrl(bool useLibravatar);
62 [[nodiscard]] Hash calculatedHash() const;
63 GRAVATAR_NO_EXPORT void processNextBackend();
64 GRAVATAR_NO_EXPORT void startNetworkManager(const QUrl &url);
65 [[nodiscard]] GRAVATAR_NO_EXPORT QUrl createUrl(bool useLibravatar);
66 [[nodiscard]] GRAVATAR_NO_EXPORT Hash calculateHash();
67 [[nodiscard]] GRAVATAR_NO_EXPORT bool cacheLookup(const Hash &hash);
68
69 std::unique_ptr<GravatarResolvUrlJobPrivate> const d;
70};
71}
Q_SCRIPTABLE Q_NOREPLY void start()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.