1 /* 2 * avatars.h 3 * Copyright (C) 2006 Remko Troncon 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * 19 */ 20 21 #ifndef AVATARS_H 22 #define AVATARS_H 23 24 #include <QPixmap> 25 #include <QMap> 26 #include <QByteArray> 27 #include <QString> 28 29 #include "iconset.h" 30 31 #define PEP_AVATAR_DATA_TN "data" 32 #define PEP_AVATAR_DATA_NS "urn:xmpp:avatar:data" 33 34 #define PEP_AVATAR_METADATA_TN "metadata" 35 #define PEP_AVATAR_METADATA_NS "urn:xmpp:avatar:metadata" 36 37 class PsiAccount; 38 class Avatar; 39 class VCardAvatar; 40 class VCardMucAvatar; 41 class VCardStaticAvatar; 42 class FileAvatar; 43 class PEPAvatar; 44 45 namespace XMPP { 46 class Jid; 47 class Resource; 48 class PubSubItem; 49 class Status; 50 } 51 52 using namespace XMPP; 53 54 //------------------------------------------------------------------------------ 55 56 class AvatarFactory : public QObject 57 { 58 Q_OBJECT 59 60 public: 61 struct UserHashes { 62 QString avatar; // current active avatar 63 QString vcard; // avatar hash just in case 64 }; 65 66 struct AvatarData { 67 QByteArray data; 68 QString metaType; 69 }; 70 71 AvatarFactory(PsiAccount* pa); 72 73 QPixmap getAvatar(const Jid& jid); 74 QPixmap getAvatarByHash(const QString& hash); 75 static AvatarData avatarDataByHash(const QString& hash); 76 UserHashes userHashes(const Jid& jid) const; 77 PsiAccount* account() const; 78 void setSelfAvatar(const QString& fileName); 79 80 void importManualAvatar(const Jid& j, const QString& fileName); 81 void removeManualAvatar(const Jid& j); 82 bool hasManualAvatar(const Jid& j); 83 84 void newMucItem(const Jid& fullJid, const Status& s); 85 QPixmap getMucAvatar(const Jid& jid); 86 87 static QString getCacheDir(); 88 static int maxAvatarSize(); 89 static QPixmap roundedAvatar(const QPixmap& pix, int rad, int avatarSize); 90 91 void statusUpdate(const Jid &jid, const XMPP::Status &status); 92 signals: 93 void avatarChanged(const Jid&); 94 95 protected slots: 96 void itemPublished(const Jid&, const QString&, const PubSubItem&); 97 void publish_success(const QString&, const PubSubItem&); 98 void resourceAvailable(const Jid&, const Resource&); 99 100 private slots: 101 void onVcardTaskFinsihed(); 102 void vcardUpdated(const Jid&, bool isMuc); 103 private: 104 105 QByteArray selfAvatarData_; 106 QString selfAvatarHash_; 107 108 PsiAccount* pa_; 109 Iconset iconset_; 110 }; 111 112 113 114 #endif 115