forked from psi-im/psi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavatars.h
107 lines (87 loc) · 2.94 KB
/
avatars.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* avatars.h
* Copyright (C) 2006 Remko Troncon
*
* 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; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef AVATARS_H
#define AVATARS_H
#include <QByteArray>
#include <QMap>
#include <QPixmap>
#include <QQueue>
#include <QString>
#include <QTimer>
#define PEP_AVATAR_DATA_TN "data"
#define PEP_AVATAR_DATA_NS "urn:xmpp:avatar:data"
#define PEP_AVATAR_METADATA_TN "metadata"
#define PEP_AVATAR_METADATA_NS "urn:xmpp:avatar:metadata"
class Avatar;
class FileAvatar;
class PEPAvatar;
class PsiAccount;
class VCardAvatar;
class VCardMucAvatar;
class VCardStaticAvatar;
namespace XMPP {
class Jid;
class Resource;
class PubSubItem;
class Status;
}
using namespace XMPP;
//------------------------------------------------------------------------------
class AvatarFactory : public QObject {
Q_OBJECT
static const int VcardReqInterval = 500; // query vcard avatars once per half second
public:
struct UserHashes {
QByteArray avatar; // current active avatar
QByteArray vcard; // avatar hash just in case
};
struct AvatarData {
QByteArray data;
QString metaType;
};
AvatarFactory(PsiAccount *pa);
~AvatarFactory();
QPixmap getAvatar(const Jid &jid);
// QPixmap getAvatarByHash(const QString& hash);
static AvatarData avatarDataByHash(const QByteArray &hash);
UserHashes userHashes(const Jid &jid) const;
PsiAccount * account() const;
void setSelfAvatar(const QString &fileName);
void importManualAvatar(const Jid &j, const QString &fileName);
void removeManualAvatar(const Jid &j);
bool hasManualAvatar(const Jid &j);
void newMucItem(const Jid &fullJid, const Status &s);
QPixmap getMucAvatar(const Jid &jid);
static QString getCacheDir();
static int maxAvatarSize();
static QPixmap roundedAvatar(const QPixmap &pix, int rad, int avatarSize);
void statusUpdate(const Jid &jid, const XMPP::Status &status);
signals:
void avatarChanged(const XMPP::Jid &);
protected slots:
void itemPublished(const XMPP::Jid &, const QString &, const PubSubItem &);
void publish_success(const QString &, const XMPP::PubSubItem &);
void resourceAvailable(const XMPP::Jid &, const XMPP::Resource &);
private slots:
void vcardUpdated(const XMPP::Jid &, bool isMuc);
private:
class Private;
Private *d;
};
#endif // AVATARS_H