1 | // SPDX-FileCopyrightText: 2017 Kitsune Ral <kitsune-ral@users.sf.net> |
---|---|
2 | // SPDX-License-Identifier: LGPL-2.1-or-later |
3 | |
4 | #pragma once |
5 | |
6 | #include "util.h" |
7 | |
8 | #include <QtCore/QUrl> |
9 | #include <QtGui/QIcon> |
10 | |
11 | #include <functional> |
12 | |
13 | namespace Quotient { |
14 | class Connection; |
15 | |
16 | class QUOTIENT_API Avatar { |
17 | public: |
18 | explicit Avatar(); |
19 | explicit Avatar(QUrl url); |
20 | |
21 | // TODO: use std::move_only_function once C++23 is here |
22 | using get_callback_t = std::function<void()>; |
23 | using upload_callback_t = std::function<void(QUrl)>; |
24 | |
25 | QImage get(Connection* connection, int dimension, |
26 | get_callback_t callback) const; |
27 | QImage get(Connection* connection, int w, int h, |
28 | get_callback_t callback) const; |
29 | |
30 | bool upload(Connection* connection, const QString& fileName, |
31 | upload_callback_t callback) const; |
32 | bool upload(Connection* connection, QIODevice* source, |
33 | upload_callback_t callback) const; |
34 | |
35 | QString mediaId() const; |
36 | QUrl url() const; |
37 | bool updateUrl(const QUrl& newUrl); |
38 | |
39 | private: |
40 | class Private; |
41 | ImplPtr<Private> d; |
42 | }; |
43 | } // namespace Quotient |
44 |