00001
00002
00003
00004
00005
00006
00007 #pragma once
00008
00009 #include <set>
00010
00011 #include <Swiften/Base/API.h>
00012 #include <Swiften/JID/JID.h>
00013 #include <Swiften/Elements/VCard.h>
00014 #include <Swiften/Elements/ErrorPayload.h>
00015 #include <Swiften/VCards/SetVCardRequest.h>
00016 #include <Swiften/Base/boost_bsignals.h>
00017
00018 namespace Swift {
00019 class JID;
00020 class VCardStorage;
00021 class IQRouter;
00022
00023 class SWIFTEN_API VCardManager : public boost::bsignals::trackable {
00024 public:
00025 VCardManager(const JID& ownJID, IQRouter* iqRouter, VCardStorage* vcardStorage);
00026 ~VCardManager();
00027
00028 VCard::ref getVCard(const JID& jid) const;
00029 VCard::ref getVCardAndRequestWhenNeeded(const JID& jid);
00030 void requestVCard(const JID& jid);
00031 void requestOwnVCard();
00032
00033 std::string getPhotoHash(const JID& jid) const;
00034
00035
00036 SetVCardRequest::ref createSetVCardRequest(VCard::ref);
00037
00038 public:
00042 boost::signal<void (const JID&, VCard::ref)> onVCardChanged;
00043
00049 boost::signal<void (VCard::ref)> onOwnVCardChanged;
00050
00051 private:
00052 void handleVCardReceived(const JID& from, VCard::ref, ErrorPayload::ref);
00053 void handleSetVCardResponse(VCard::ref, ErrorPayload::ref);
00054 void setVCard(const JID& jid, VCard::ref vcard);
00055
00056 private:
00057 JID ownJID;
00058 IQRouter* iqRouter;
00059 VCardStorage* storage;
00060 std::set<JID> requestedVCards;
00061 };
00062 }