1 /* 2 * vcardfactory.h - class for caching vCards 3 * Copyright (C) 2003 Michail Pishchagin 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 VCARDFACTORY_H 22 #define VCARDFACTORY_H 23 24 #include <QObject> 25 #include <QMap> 26 #include <QHash> 27 #include <QStringList> 28 29 namespace XMPP { 30 class VCard; 31 class Jid; 32 class Task; 33 class JT_VCard; 34 } 35 using namespace XMPP; 36 37 class PsiAccount; 38 39 class VCardFactory : public QObject 40 { 41 Q_OBJECT 42 43 public: 44 static VCardFactory* instance(); 45 VCard vcard(const Jid &); 46 const VCard mucVcard(const Jid &j) const; 47 void setVCard(const Jid &, const VCard &, bool notifyPhoto = true); 48 void setVCard(const PsiAccount* account, const VCard &v, QObject* obj = 0, const char* slot = 0); 49 void setTargetVCard(const PsiAccount* account, const VCard &v, const Jid &mucJid, QObject* obj, const char* slot); 50 JT_VCard *getVCard(const Jid &, Task *rootTask, const QObject *, const char *slot, 51 bool cacheVCard = true, bool isMuc = false, bool notifyPhoto = true); 52 53 signals: 54 void vcardChanged(const Jid&); 55 void vcardPhotoAvailable(const Jid&, bool isMuc); // dedicated for AvatarFactory. it will almost always work except requests from AvatarFactory 56 57 protected: 58 void checkLimit(const QString &jid, const VCard &vcard); 59 60 private slots: 61 void updateVCardFinished(); 62 void taskFinished(); 63 void mucTaskFinished(); 64 65 private: 66 VCardFactory(); 67 ~VCardFactory(); 68 69 static VCardFactory* instance_; 70 const int dictSize_; 71 QStringList vcardList_; 72 QMap<QString,VCard> vcardDict_; 73 QMap<QString, QHash<QString,VCard> > mucVcardDict_; // QHash in case of big mucs 74 75 void saveVCard(const Jid &, const VCard &, bool notifyPhoto); 76 }; 77 78 #endif 79