1 /*
2     Copyright © 2017-2019 by The qTox Project Contributors
3 
4     This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6     qTox is libre software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10 
11     qTox is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with qTox.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include <QObject>
21 #include "src/model/interface.h"
22 #include "src/core/toxpk.h"
23 #include "iprofileinfo.h"
24 
25 class Core;
26 class QFile;
27 class QPoint;
28 class Profile;
29 
30 class ProfileInfo : public QObject, public IProfileInfo
31 {
32     Q_OBJECT
33 public:
34     ProfileInfo(Core* core, Profile* profile);
35 
36     bool setPassword(const QString& password) override;
37     bool deletePassword() override;
38     bool isEncrypted() const override;
39 
40     void copyId() const override;
41 
42     void setUsername(const QString& name) override;
43     void setStatusMessage(const QString& status) override;
44 
45     QString getProfileName() const override;
46     RenameResult renameProfile(const QString& name) override;
47     SaveResult exportProfile(const QString& path) const override;
48     QStringList removeProfile() override;
49     void logout() override;
50 
51     void copyQr(const QImage& image) const override;
52     SaveResult saveQr(const QImage& image, const QString& path) const override;
53 
54     SetAvatarResult setAvatar(const QString& path) override;
55     void removeAvatar() override;
56 
57     SIGNAL_IMPL(ProfileInfo, idChanged, const ToxId& id)
58     SIGNAL_IMPL(ProfileInfo, usernameChanged, const QString& name)
59     SIGNAL_IMPL(ProfileInfo, statusMessageChanged, const QString& message)
60 
61 private:
62     IProfileInfo::SetAvatarResult createAvatarFromFile(QFile& file, QByteArray& avatar);
63     IProfileInfo::SetAvatarResult byteArrayToPng(QByteArray inData, QByteArray& outPng);
64     IProfileInfo::SetAvatarResult scalePngToAvatar(QByteArray& avatar);
65     Profile* const profile;
66     Core* const core;
67 };
68