summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-08-22 08:55:08 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-08-24 17:10:23 (GMT)
commitb6a34463dfcedd454ab42230a47cdb7294a76f21 (patch)
tree832b0243325451932c0d15e9e33d53948fce0110 /Swiften/Avatars
parent6e4b357141a6d09632f1e96d0eaf54f79daf52c9 (diff)
downloadswift-contrib-b6a34463dfcedd454ab42230a47cdb7294a76f21.zip
swift-contrib-b6a34463dfcedd454ab42230a47cdb7294a76f21.tar.bz2
Implemented VCardManager.
Diffstat (limited to 'Swiften/Avatars')
-rw-r--r--Swiften/Avatars/AvatarFileStorage.cpp7
-rw-r--r--Swiften/Avatars/AvatarFileStorage.h1
-rw-r--r--Swiften/Avatars/AvatarManager.cpp63
-rw-r--r--Swiften/Avatars/AvatarManager.h21
-rw-r--r--Swiften/Avatars/AvatarMemoryStorage.h32
-rw-r--r--Swiften/Avatars/AvatarStorage.h1
-rw-r--r--Swiften/Avatars/UnitTest/AvatarManagerTest.cpp146
-rw-r--r--Swiften/Avatars/UnitTest/MockAvatarManager.cpp32
-rw-r--r--Swiften/Avatars/UnitTest/MockAvatarManager.h23
9 files changed, 168 insertions, 158 deletions
diff --git a/Swiften/Avatars/AvatarFileStorage.cpp b/Swiften/Avatars/AvatarFileStorage.cpp
index a0ebd21..57bb1be 100644
--- a/Swiften/Avatars/AvatarFileStorage.cpp
+++ b/Swiften/Avatars/AvatarFileStorage.cpp
@@ -34,4 +34,11 @@ boost::filesystem::path AvatarFileStorage::getAvatarPath(const String& hash) con
return path_ / hash.getUTF8String();
}
+ByteArray AvatarFileStorage::getAvatar(const String& hash) const {
+ ByteArray data;
+ data.readFromFile(getAvatarPath(hash).string());
+ return data;
+}
+
+
}
diff --git a/Swiften/Avatars/AvatarFileStorage.h b/Swiften/Avatars/AvatarFileStorage.h
index 6318c60..5ade779 100644
--- a/Swiften/Avatars/AvatarFileStorage.h
+++ b/Swiften/Avatars/AvatarFileStorage.h
@@ -20,6 +20,7 @@ namespace Swift {
virtual bool hasAvatar(const String& hash) const;
virtual void addAvatar(const String& hash, const ByteArray& avatar);
+ virtual ByteArray getAvatar(const String& hash) const;
virtual boost::filesystem::path getAvatarPath(const String& hash) const;
diff --git a/Swiften/Avatars/AvatarManager.cpp b/Swiften/Avatars/AvatarManager.cpp
index 3861520..33b1bee 100644
--- a/Swiften/Avatars/AvatarManager.cpp
+++ b/Swiften/Avatars/AvatarManager.cpp
@@ -15,18 +15,13 @@
#include "Swiften/StringCodecs/Hexify.h"
#include "Swiften/Avatars/AvatarStorage.h"
#include "Swiften/MUC/MUCRegistry.h"
+#include "Swiften/VCards/VCardManager.h"
namespace Swift {
-AvatarManager::AvatarManager(StanzaChannel* stanzaChannel, IQRouter* iqRouter, AvatarStorage* avatarStorage, MUCRegistry* mucRegistry) : stanzaChannel_(stanzaChannel), iqRouter_(iqRouter), avatarStorage_(avatarStorage), mucRegistry_(mucRegistry) {
+AvatarManager::AvatarManager(VCardManager* vcardManager, StanzaChannel* stanzaChannel, AvatarStorage* avatarStorage, MUCRegistry* mucRegistry) : vcardManager_(vcardManager), stanzaChannel_(stanzaChannel), avatarStorage_(avatarStorage), mucRegistry_(mucRegistry) {
stanzaChannel->onPresenceReceived.connect(boost::bind(&AvatarManager::handlePresenceReceived, this, _1));
-}
-
-AvatarManager::AvatarManager() {
- stanzaChannel_ = NULL;
- iqRouter_ = NULL;
- avatarStorage_ = NULL;
- mucRegistry_ = NULL;
+ vcardManager_->onVCardChanged.connect(boost::bind(&AvatarManager::handleVCardChanged, this, _1, _2));
}
AvatarManager::~AvatarManager() {
@@ -39,50 +34,30 @@ void AvatarManager::setMUCRegistry(MUCRegistry* mucRegistry) {
void AvatarManager::handlePresenceReceived(boost::shared_ptr<Presence> presence) {
boost::shared_ptr<VCardUpdate> update = presence->getPayload<VCardUpdate>();
- if (!update) {
+ if (!update || presence->getPayload<ErrorPayload>()) {
return;
}
- if (presence->getPayload<ErrorPayload>()) {
+ JID from = getAvatarJID(presence->getFrom());
+ if (getAvatarHash(from) == update->getPhotoHash()) {
return;
}
- JID from = getAvatarJID(presence->getFrom());
- String& hash = avatarHashes_[from];
- if (hash != update->getPhotoHash()) {
- String newHash = update->getPhotoHash();
- if (avatarStorage_->hasAvatar(newHash)) {
- setAvatarHash(from, newHash);
- }
- else {
- boost::shared_ptr<GetVCardRequest> request(new GetVCardRequest(from, iqRouter_));
- request->onResponse.connect(boost::bind(&AvatarManager::handleVCardReceived, this, from, newHash, _1, _2));
- request->send();
- }
+ if (avatarStorage_->hasAvatar(update->getPhotoHash())) {
+ setAvatarHash(from, update->getPhotoHash());
+ }
+ else {
+ vcardManager_->requestVCard(from);
}
}
-void AvatarManager::handleVCardReceived(const JID& from, const String& promisedHash, boost::shared_ptr<VCard> vCard, const boost::optional<ErrorPayload>& error) {
- if (error) {
- // FIXME: What to do here?
- std::cerr << "Warning: " << from << ": Could not get vCard" << std::endl;
- return;
- }
+void AvatarManager::handleVCardChanged(const JID& from, VCard::ref vCard) {
if (!vCard) {
std::cerr << "Warning: " << from << ": null vcard payload" << std::endl;
- //FIXME: Why could this happen?
return;
}
- String realHash = Hexify::hexify(SHA1::getHash(vCard->getPhoto()));
- if (promisedHash != realHash) {
- std::cerr << "Warning: " << from << ": Got different vCard photo hash (" << promisedHash << " != " << realHash << ")" << std::endl;
- }
- avatarStorage_->addAvatar(realHash, vCard->getPhoto());
- setAvatarHash(from, realHash);
-}
-void AvatarManager::setAvatar(const JID& jid, const ByteArray& avatar) {
- String hash = Hexify::hexify(SHA1::getHash(avatar));
- avatarStorage_->addAvatar(hash, avatar);
- setAvatarHash(getAvatarJID(jid), hash);
+ String hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto()));
+ avatarStorage_->addAvatar(hash, vCard->getPhoto());
+ setAvatarHash(from, hash);
}
void AvatarManager::setAvatarHash(const JID& from, const String& hash) {
@@ -90,6 +65,14 @@ void AvatarManager::setAvatarHash(const JID& from, const String& hash) {
onAvatarChanged(from, hash);
}
+/*
+void AvatarManager::setAvatar(const JID& jid, const ByteArray& avatar) {
+ String hash = Hexify::hexify(SHA1::getHash(avatar));
+ avatarStorage_->addAvatar(hash, avatar);
+ setAvatarHash(getAvatarJID(jid), hash);
+}
+*/
+
String AvatarManager::getAvatarHash(const JID& jid) const {
std::map<JID, String>::const_iterator i = avatarHashes_.find(getAvatarJID(jid));
if (i != avatarHashes_.end()) {
diff --git a/Swiften/Avatars/AvatarManager.h b/Swiften/Avatars/AvatarManager.h
index ad4b30f..543d167 100644
--- a/Swiften/Avatars/AvatarManager.h
+++ b/Swiften/Avatars/AvatarManager.h
@@ -9,9 +9,9 @@
#include <boost/filesystem.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
-#include "Swiften/Base/boost_bsignals.h"
#include <map>
+#include "Swiften/Base/boost_bsignals.h"
#include "Swiften/JID/JID.h"
#include "Swiften/Elements/Presence.h"
#include "Swiften/Elements/VCard.h"
@@ -21,35 +21,32 @@ namespace Swift {
class MUCRegistry;
class AvatarStorage;
class StanzaChannel;
- class IQRouter;
+ class VCardManager;
class AvatarManager {
public:
- AvatarManager(StanzaChannel*, IQRouter*, AvatarStorage*, MUCRegistry* = NULL);
+ AvatarManager(VCardManager*, StanzaChannel*, AvatarStorage*, MUCRegistry* = NULL);
virtual ~AvatarManager();
virtual void setMUCRegistry(MUCRegistry*);
- virtual String getAvatarHash(const JID&) const;
virtual boost::filesystem::path getAvatarPath(const JID&) const;
- virtual void setAvatar(const JID&, const ByteArray& avatar);
- public:
- boost::signal<void (const JID&, const String&)> onAvatarChanged;
+// virtual void setAvatar(const JID&, const ByteArray& avatar);*/
- protected:
- /** Used only for testing. Leads to a non-functional object. */
- AvatarManager();
+ public:
+ boost::signal<void (const JID&, const String& /*hash*/)> onAvatarChanged;
private:
void handlePresenceReceived(boost::shared_ptr<Presence>);
- void handleVCardReceived(const JID& from, const String& hash, boost::shared_ptr<VCard>, const boost::optional<ErrorPayload>&);
+ void handleVCardChanged(const JID& from, VCard::ref);
void setAvatarHash(const JID& from, const String& hash);
JID getAvatarJID(const JID& o) const;
+ String getAvatarHash(const JID&) const;
private:
+ VCardManager* vcardManager_;
StanzaChannel* stanzaChannel_;
- IQRouter* iqRouter_;
AvatarStorage* avatarStorage_;
MUCRegistry* mucRegistry_;
std::map<JID, String> avatarHashes_;
diff --git a/Swiften/Avatars/AvatarMemoryStorage.h b/Swiften/Avatars/AvatarMemoryStorage.h
new file mode 100644
index 0000000..f60f603
--- /dev/null
+++ b/Swiften/Avatars/AvatarMemoryStorage.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/Base/String.h"
+#include "Swiften/Base/ByteArray.h"
+#include "Swiften/Avatars/AvatarStorage.h"
+
+namespace Swift {
+ class AvatarMemoryStorage : public AvatarStorage {
+ public:
+ virtual bool hasAvatar(const String& hash) const { return avatars.find(hash) != avatars.end(); }
+ virtual void addAvatar(const String& hash, const ByteArray& avatar) { avatars[hash] = avatar; }
+ virtual ByteArray getAvatar(const String& hash) const {
+ std::map<String, ByteArray>::const_iterator i = avatars.find(hash);
+ return i == avatars.end() ? ByteArray() : i->second;
+ }
+
+ virtual boost::filesystem::path getAvatarPath(const String& hash) const {
+ return boost::filesystem::path();
+ }
+
+ private:
+ std::map<String, ByteArray> avatars;
+ };
+}
diff --git a/Swiften/Avatars/AvatarStorage.h b/Swiften/Avatars/AvatarStorage.h
index bd8aa49..d699f40 100644
--- a/Swiften/Avatars/AvatarStorage.h
+++ b/Swiften/Avatars/AvatarStorage.h
@@ -18,6 +18,7 @@ namespace Swift {
virtual bool hasAvatar(const String& hash) const = 0;
virtual void addAvatar(const String& hash, const ByteArray& avatar) = 0;
+ virtual ByteArray getAvatar(const String& hash) const = 0;
virtual boost::filesystem::path getAvatarPath(const String& hash) const = 0;
};
diff --git a/Swiften/Avatars/UnitTest/AvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/AvatarManagerTest.cpp
index f954aa1..858d257 100644
--- a/Swiften/Avatars/UnitTest/AvatarManagerTest.cpp
+++ b/Swiften/Avatars/UnitTest/AvatarManagerTest.cpp
@@ -6,24 +6,32 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <boost/bind.hpp>
#include "Swiften/Elements/VCardUpdate.h"
#include "Swiften/Avatars/AvatarManager.h"
-#include "Swiften/Avatars/AvatarStorage.h"
+#include "Swiften/Avatars/AvatarMemoryStorage.h"
+#include "Swiften/VCards/VCardMemoryStorage.h"
+#include "Swiften/VCards/VCardManager.h"
#include "Swiften/MUC/MUCRegistry.h"
#include "Swiften/Queries/IQRouter.h"
#include "Swiften/Client/DummyStanzaChannel.h"
+#include "Swiften/StringCodecs/SHA1.h"
+#include "Swiften/StringCodecs/Hexify.h"
using namespace Swift;
class AvatarManagerTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(AvatarManagerTest);
- CPPUNIT_TEST(testUpdate_UpdateNewHash);
+ CPPUNIT_TEST(testUpdate_NewHashNewVCardRequestsVCard);
+ CPPUNIT_TEST(testUpdate_NewHashStoresAvatarAndEmitsNotificationOnVCardReceive);
+ CPPUNIT_TEST(testUpdate_KnownHash);
+ CPPUNIT_TEST(testUpdate_KnownHashFromDifferentUserDoesNotRequestVCardButTriggersNotification);
/*&
CPPUNIT_TEST(testUpdate_UpdateNewHashAlreadyHaveAvatar);
CPPUNIT_TEST(testUpdate_UpdateNewHashFromMUC);
CPPUNIT_TEST(testUpdate_UpdateSameHash);*/
- CPPUNIT_TEST(testUpdate_UpdateWithError);
+ //CPPUNIT_TEST(testUpdate_UpdateWithError);
/*
CPPUNIT_TEST(testUpdate_UpdateNewHashSameThanOtherUser);
CPPUNIT_TEST(testReceiveVCard);
@@ -33,99 +41,135 @@ class AvatarManagerTest : public CppUnit::TestFixture {
public:
void setUp() {
- stanzaChannel_ = new DummyStanzaChannel();
- iqRouter_ = new IQRouter(stanzaChannel_);
- mucRegistry_ = new DummyMUCRegistry();
- avatarStorage_ = new DummyAvatarStorage();
+ ownJID = JID("foo@fum.com/bum");
+ stanzaChannel = new DummyStanzaChannel();
+ iqRouter = new IQRouter(stanzaChannel);
+ mucRegistry = new DummyMUCRegistry();
+ avatarStorage = new AvatarMemoryStorage();
+ vcardStorage = new VCardMemoryStorage();
+ vcardManager = new VCardManager(ownJID, iqRouter, vcardStorage);
+ avatar1 = ByteArray("abcdefg");
+ avatar1Hash = Hexify::hexify(SHA1::getHash(avatar1));
+ user1 = JID("user1@bar.com/bla");
+ user2 = JID("user2@foo.com/baz");
}
void tearDown() {
- delete avatarStorage_;
- delete mucRegistry_;
- delete iqRouter_;
- delete stanzaChannel_;
+ delete vcardManager;
+ delete vcardStorage;
+ delete avatarStorage;
+ delete mucRegistry;
+ delete iqRouter;
+ delete stanzaChannel;
}
- void testUpdate_UpdateNewHash() {
+ void testUpdate_NewHashNewVCardRequestsVCard() {
std::auto_ptr<AvatarManager> testling = createManager();
- stanzaChannel_->onPresenceReceived(createPresenceWithPhotoHash());
+ stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel_->sentStanzas.size()));
- CPPUNIT_ASSERT(stanzaChannel_->isRequestAtIndex<VCard>(0, JID("foo@bar.com"), IQ::Get));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
+ CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, user1.toBare(), IQ::Get));
}
- void testUpdate_UpdateNewHashAlreadyHaveAvatar() {
- avatarStorage_->addAvatar("aef56135bcce35eb24a43fcd684005b4ca286497", ByteArray("ghij"));
- std::auto_ptr<AvatarManager> testling = createManager();
- stanzaChannel_->onPresenceReceived(createPresenceWithPhotoHash());
-
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(stanzaChannel_->sentStanzas.size()));
- }
-/*
- void testUpdate_UpdateNewHashFromMUC() {
+ void testUpdate_NewHashStoresAvatarAndEmitsNotificationOnVCardReceive() {
std::auto_ptr<AvatarManager> testling = createManager();
+ stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
+ stanzaChannel->onIQReceived(createVCardResult(avatar1));
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size()));
+ CPPUNIT_ASSERT_EQUAL(user1.toBare(), changes[0].first);
+ CPPUNIT_ASSERT_EQUAL(avatar1Hash, changes[0].second);
+ CPPUNIT_ASSERT(avatarStorage->hasAvatar(avatar1Hash));
+ CPPUNIT_ASSERT_EQUAL(avatar1, avatarStorage->getAvatar(avatar1Hash));
}
- void testUpdate_UpdateSameHash() {
+ void testUpdate_KnownHash() {
std::auto_ptr<AvatarManager> testling = createManager();
- }
+ stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
+ stanzaChannel->onIQReceived(createVCardResult(avatar1));
+ changes.clear();
+ stanzaChannel->sentStanzas.clear();
- void testUpdate_UpdateNewHashSameThanOtherUser() {
- std::auto_ptr<AvatarManager> testling = createManager();
- }
+ stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
- void testReceiveVCard() {
- std::auto_ptr<AvatarManager> testling = createManager();
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(stanzaChannel->sentStanzas.size()));
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changes.size()));
}
- void testGetAvatarPath() {
+ void testUpdate_KnownHashFromDifferentUserDoesNotRequestVCardButTriggersNotification() {
std::auto_ptr<AvatarManager> testling = createManager();
+ stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
+ stanzaChannel->onIQReceived(createVCardResult(avatar1));
+ changes.clear();
+ stanzaChannel->sentStanzas.clear();
+
+ stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user2, avatar1Hash));
+
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(stanzaChannel->sentStanzas.size()));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size()));
+ CPPUNIT_ASSERT_EQUAL(user2.toBare(), changes[0].first);
+ CPPUNIT_ASSERT_EQUAL(avatar1Hash, changes[0].second);
}
- void testGetAvatarPathFromMUC() {
+/*
+ void testUpdate_UpdateNewHashFromMUC() {
std::auto_ptr<AvatarManager> testling = createManager();
}
+
*/
- void testUpdate_UpdateWithError() {
+ /*void testUpdate_UpdateWithError() {
std::auto_ptr<AvatarManager> testling = createManager();
boost::shared_ptr<Presence> update = createPresenceWithPhotoHash();
update->addPayload(boost::shared_ptr<ErrorPayload>(new ErrorPayload()));
stanzaChannel_->onPresenceReceived(update);
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(stanzaChannel_->sentStanzas.size()));
- }
+ }*/
private:
std::auto_ptr<AvatarManager> createManager() {
- return std::auto_ptr<AvatarManager>(new AvatarManager(stanzaChannel_, iqRouter_, avatarStorage_, mucRegistry_));
+ std::auto_ptr<AvatarManager> result(new AvatarManager(vcardManager, stanzaChannel, avatarStorage, mucRegistry));
+ result->onAvatarChanged.connect(boost::bind(&AvatarManagerTest::handleAvatarChanged, this, _1, _2));
+ return result;
}
- boost::shared_ptr<Presence> createPresenceWithPhotoHash() {
+ boost::shared_ptr<Presence> createPresenceWithPhotoHash(const JID& jid, const String& hash) {
boost::shared_ptr<Presence> presence(new Presence());
- presence->setFrom(JID("foo@bar.com/baz"));
- presence->addPayload(boost::shared_ptr<VCardUpdate>(new VCardUpdate("aef56135bcce35eb24a43fcd684005b4ca286497")));
+ presence->setFrom(jid);
+ presence->addPayload(boost::shared_ptr<VCardUpdate>(new VCardUpdate(hash)));
return presence;
}
+ IQ::ref createVCardResult(const ByteArray& avatar) {
+ VCard::ref vcard(new VCard());
+ vcard->setPhoto(avatar);
+ return IQ::createResult(JID("baz@fum.com"), stanzaChannel->sentStanzas[0]->getID(), vcard);
+ }
+
+ void handleAvatarChanged(const JID& jid, const String& hash) {
+ changes.push_back(std::pair<JID,String>(jid, hash));
+ }
+
private:
struct DummyMUCRegistry : public MUCRegistry {
bool isMUC(const JID& jid) const { return std::find(mucs_.begin(), mucs_.end(), jid) != mucs_.end(); }
std::vector<JID> mucs_;
};
- struct DummyAvatarStorage : public AvatarStorage {
- virtual bool hasAvatar(const String& hash) const { return avatars.find(hash) != avatars.end(); }
- virtual void addAvatar(const String& hash, const ByteArray& avatar) { avatars[hash] = avatar; }
- virtual boost::filesystem::path getAvatarPath(const String& hash) const {
- return boost::filesystem::path("/avatars") / hash.getUTF8String();
- }
- std::map<String, ByteArray> avatars;
- };
- DummyStanzaChannel* stanzaChannel_;
- IQRouter* iqRouter_;
- DummyMUCRegistry* mucRegistry_;
- DummyAvatarStorage* avatarStorage_;
+
+ JID ownJID;
+ DummyStanzaChannel* stanzaChannel;
+ IQRouter* iqRouter;
+ DummyMUCRegistry* mucRegistry;
+ AvatarMemoryStorage* avatarStorage;
+ VCardManager* vcardManager;
+ VCardMemoryStorage* vcardStorage;
+ ByteArray avatar1;
+ String avatar1Hash;
+ std::vector<std::pair<JID,String> > changes;
+ JID user1;
+ JID user2;
};
CPPUNIT_TEST_SUITE_REGISTRATION(AvatarManagerTest);
diff --git a/Swiften/Avatars/UnitTest/MockAvatarManager.cpp b/Swiften/Avatars/UnitTest/MockAvatarManager.cpp
deleted file mode 100644
index 4a96e01..0000000
--- a/Swiften/Avatars/UnitTest/MockAvatarManager.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include "Swiften/Avatars/UnitTest/MockAvatarManager.h"
-
-namespace Swift {
-
-MockAvatarManager::MockAvatarManager() {
-
-}
-
-MockAvatarManager::~MockAvatarManager() {
-
-}
-
-String MockAvatarManager::getAvatarHash(const JID& jid) const {
- return jid.toBare();
-}
-
-boost::filesystem::path MockAvatarManager::getAvatarPath(const JID& jid) const {
- return jid.getResource().getUTF8String();
-}
-
-void MockAvatarManager::setAvatar(const JID&, const ByteArray&) {
-
-}
-
-}
-
diff --git a/Swiften/Avatars/UnitTest/MockAvatarManager.h b/Swiften/Avatars/UnitTest/MockAvatarManager.h
deleted file mode 100644
index 9f31f12..0000000
--- a/Swiften/Avatars/UnitTest/MockAvatarManager.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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 "Swiften/Avatars/AvatarManager.h"
-#include "Swiften/Client/DummyStanzaChannel.h"
-
-namespace Swift {
- class MockAvatarManager : public AvatarManager {
- public:
- MockAvatarManager();
- virtual ~MockAvatarManager();
- virtual String getAvatarHash(const JID&) const;
- virtual boost::filesystem::path getAvatarPath(const JID&) const;
- virtual void setAvatar(const JID&, const ByteArray& avatar);
- private:
- DummyStanzaChannel channel_;
- };
-}