summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-09-12 18:29:39 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-09-13 19:19:52 (GMT)
commitef1052bbdb315aaa1c6254098ea05638d9a25b2f (patch)
tree482277f649f6c0fc00027514ea8986861fe33437 /Swiften/Avatars
parent3ae8cccfe9c6bfed5dda5f024a5cb046ccfc9793 (diff)
downloadswift-ef1052bbdb315aaa1c6254098ea05638d9a25b2f.zip
swift-ef1052bbdb315aaa1c6254098ea05638d9a25b2f.tar.bz2
Added presence notifier.
Diffstat (limited to 'Swiften/Avatars')
-rw-r--r--Swiften/Avatars/AvatarManager.h2
-rw-r--r--Swiften/Avatars/AvatarManagerImpl.cpp8
-rw-r--r--Swiften/Avatars/AvatarManagerImpl.h1
-rw-r--r--Swiften/Avatars/DummyAvatarManager.h32
-rw-r--r--Swiften/Avatars/NullAvatarManager.h4
5 files changed, 47 insertions, 0 deletions
diff --git a/Swiften/Avatars/AvatarManager.h b/Swiften/Avatars/AvatarManager.h
index 74e58f7..d40c3c0 100644
--- a/Swiften/Avatars/AvatarManager.h
+++ b/Swiften/Avatars/AvatarManager.h
@@ -9,6 +9,7 @@
#include <boost/filesystem.hpp>
#include "Swiften/Base/boost_bsignals.h"
+#include "Swiften/Base/ByteArray.h"
namespace Swift {
class JID;
@@ -17,6 +18,7 @@ namespace Swift {
public:
virtual ~AvatarManager();
+ virtual ByteArray getAvatar(const JID&) const = 0;
virtual boost::filesystem::path getAvatarPath(const JID&) const = 0;
boost::signal<void (const JID&)> onAvatarChanged;
diff --git a/Swiften/Avatars/AvatarManagerImpl.cpp b/Swiften/Avatars/AvatarManagerImpl.cpp
index 384994b..9813aed 100644
--- a/Swiften/Avatars/AvatarManagerImpl.cpp
+++ b/Swiften/Avatars/AvatarManagerImpl.cpp
@@ -11,6 +11,7 @@
#include "Swiften/Avatars/VCardUpdateAvatarManager.h"
#include "Swiften/Avatars/VCardAvatarManager.h"
#include "Swiften/Avatars/AvatarStorage.h"
+#include "Swiften/Base/ByteArray.h"
namespace Swift {
@@ -39,5 +40,12 @@ boost::filesystem::path AvatarManagerImpl::getAvatarPath(const JID& jid) const {
return boost::filesystem::path();
}
+ByteArray AvatarManagerImpl::getAvatar(const JID& jid) const {
+ String hash = combinedAvatarProvider.getAvatarHash(jid);
+ if (!hash.isEmpty()) {
+ return avatarStorage->getAvatar(hash);
+ }
+ return ByteArray();
+}
}
diff --git a/Swiften/Avatars/AvatarManagerImpl.h b/Swiften/Avatars/AvatarManagerImpl.h
index f533160..a28d490 100644
--- a/Swiften/Avatars/AvatarManagerImpl.h
+++ b/Swiften/Avatars/AvatarManagerImpl.h
@@ -33,6 +33,7 @@ namespace Swift {
virtual ~AvatarManagerImpl();
virtual boost::filesystem::path getAvatarPath(const JID&) const;
+ virtual ByteArray getAvatar(const JID&) const;
private:
CombinedAvatarProvider combinedAvatarProvider;
diff --git a/Swiften/Avatars/DummyAvatarManager.h b/Swiften/Avatars/DummyAvatarManager.h
new file mode 100644
index 0000000..db63b05
--- /dev/null
+++ b/Swiften/Avatars/DummyAvatarManager.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <map>
+
+#include "Swiften/Avatars/AvatarManager.h"
+
+namespace Swift {
+ class DummyAvatarManager : public AvatarManager {
+ public:
+ virtual boost::filesystem::path getAvatarPath(const JID&) const {
+ return boost::filesystem::path();
+ }
+
+ virtual ByteArray getAvatar(const JID& jid) const {
+ std::map<JID, ByteArray>::const_iterator i = avatars.find(jid);
+ if (i != avatars.end()) {
+ return i->second;
+ }
+ else {
+ return ByteArray();
+ }
+ }
+
+ std::map<JID, ByteArray> avatars;
+ };
+}
diff --git a/Swiften/Avatars/NullAvatarManager.h b/Swiften/Avatars/NullAvatarManager.h
index 7f3c646..e96ed7a 100644
--- a/Swiften/Avatars/NullAvatarManager.h
+++ b/Swiften/Avatars/NullAvatarManager.h
@@ -14,5 +14,9 @@ namespace Swift {
virtual boost::filesystem::path getAvatarPath(const JID&) const {
return boost::filesystem::path();
}
+
+ virtual ByteArray getAvatar(const JID&) const {
+ return ByteArray();
+ }
};
}