summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Avatars/AvatarManager.cpp6
-rw-r--r--Swiften/Avatars/AvatarManager.h1
-rw-r--r--Swiften/Elements/VCardUpdate.h2
3 files changed, 8 insertions, 1 deletions
diff --git a/Swiften/Avatars/AvatarManager.cpp b/Swiften/Avatars/AvatarManager.cpp
index c15d002..6a1efc6 100644
--- a/Swiften/Avatars/AvatarManager.cpp
+++ b/Swiften/Avatars/AvatarManager.cpp
@@ -49,6 +49,12 @@ void AvatarManager::handleVCardReceived(const JID& from, const String& promisedH
setAvatarHash(from, realHash);
}
+void AvatarManager::setAvatar(const JID& jid, const ByteArray& avatar) {
+ String hash = SHA1::getHexHash(avatar);
+ avatarStorage_->addAvatar(hash, avatar);
+ setAvatarHash(getAvatarJID(jid), hash);
+}
+
void AvatarManager::setAvatarHash(const JID& from, const String& hash) {
avatarHashes_[from] = hash;
onAvatarChanged(from, hash);
diff --git a/Swiften/Avatars/AvatarManager.h b/Swiften/Avatars/AvatarManager.h
index 13c6cb7..984ce19 100644
--- a/Swiften/Avatars/AvatarManager.h
+++ b/Swiften/Avatars/AvatarManager.h
@@ -23,6 +23,7 @@ namespace Swift {
String getAvatarHash(const JID&) const;
boost::filesystem::path getAvatarPath(const JID&) const;
+ void setAvatar(const JID&, const ByteArray& avatar);
public:
boost::signal<void (const JID&, const String&)> onAvatarChanged;
diff --git a/Swiften/Elements/VCardUpdate.h b/Swiften/Elements/VCardUpdate.h
index b6c8ebd..6bb79cc 100644
--- a/Swiften/Elements/VCardUpdate.h
+++ b/Swiften/Elements/VCardUpdate.h
@@ -6,7 +6,7 @@
namespace Swift {
class VCardUpdate : public Payload {
public:
- VCardUpdate() {}
+ VCardUpdate(const String& photoHash = "") : photoHash_(photoHash) {}
void setPhotoHash(const String& photoHash) { photoHash_ = photoHash; }
const String& getPhotoHash() { return photoHash_; }