summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-09-10 13:16:00 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-09-11 21:53:46 (GMT)
commitbc6a510af449b6e383a11fc20c9859b8bcac247c (patch)
tree70288194b0f75d9d268c2ac94d70291d988a0bf4 /Swiften/Avatars
parent8bdc3c2e2e520407027ac3a3e09d7af8054a0e5b (diff)
downloadswift-bc6a510af449b6e383a11fc20c9859b8bcac247c.zip
swift-bc6a510af449b6e383a11fc20c9859b8bcac247c.tar.bz2
Make AvatarManager abstract
Diffstat (limited to 'Swiften/Avatars')
-rw-r--r--Swiften/Avatars/AvatarManager.cpp30
-rw-r--r--Swiften/Avatars/AvatarManager.h25
-rw-r--r--Swiften/Avatars/AvatarManagerImpl.cpp43
-rw-r--r--Swiften/Avatars/AvatarManagerImpl.h43
-rw-r--r--Swiften/Avatars/NullAvatarManager.h18
-rw-r--r--Swiften/Avatars/SConscript1
6 files changed, 107 insertions, 53 deletions
diff --git a/Swiften/Avatars/AvatarManager.cpp b/Swiften/Avatars/AvatarManager.cpp
index 6ad39fb..a2b7200 100644
--- a/Swiften/Avatars/AvatarManager.cpp
+++ b/Swiften/Avatars/AvatarManager.cpp
@@ -6,39 +6,9 @@
#include "Swiften/Avatars/AvatarManager.h"
-#include <boost/bind.hpp>
-
-#include "Swiften/Avatars/VCardUpdateAvatarManager.h"
-#include "Swiften/Avatars/VCardAvatarManager.h"
-#include "Swiften/Avatars/AvatarStorage.h"
-
namespace Swift {
-AvatarManager::AvatarManager(VCardManager* vcardManager, StanzaChannel* stanzaChannel, AvatarStorage* avatarStorage, MUCRegistry* mucRegistry) : avatarStorage(avatarStorage) {
- vcardUpdateAvatarManager = new VCardUpdateAvatarManager(vcardManager, stanzaChannel, avatarStorage, mucRegistry);
- combinedAvatarProvider.addProvider(vcardUpdateAvatarManager);
-
- vcardAvatarManager = new VCardAvatarManager(vcardManager, avatarStorage, mucRegistry);
- combinedAvatarProvider.addProvider(vcardAvatarManager);
-
- combinedAvatarProvider.onAvatarChanged.connect(boost::ref(onAvatarChanged));
-}
-
AvatarManager::~AvatarManager() {
- combinedAvatarProvider.removeProvider(vcardAvatarManager);
- delete vcardAvatarManager;
- combinedAvatarProvider.removeProvider(vcardUpdateAvatarManager);
- delete vcardUpdateAvatarManager;
-}
-
-boost::filesystem::path AvatarManager::getAvatarPath(const JID& jid) const {
- String hash = combinedAvatarProvider.getAvatarHash(jid);
- if (!hash.isEmpty()) {
- std::cout << "getAvatar " << jid << " " << avatarStorage->getAvatarPath(hash) << std::endl;
- return avatarStorage->getAvatarPath(hash);
- }
- return boost::filesystem::path();
}
-
}
diff --git a/Swiften/Avatars/AvatarManager.h b/Swiften/Avatars/AvatarManager.h
index 0309b20..74e58f7 100644
--- a/Swiften/Avatars/AvatarManager.h
+++ b/Swiften/Avatars/AvatarManager.h
@@ -7,39 +7,18 @@
#pragma once
#include <boost/filesystem.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/optional.hpp>
-#include <map>
#include "Swiften/Base/boost_bsignals.h"
-#include "Swiften/JID/JID.h"
-#include "Swiften/Elements/Presence.h"
-#include "Swiften/Elements/VCard.h"
-#include "Swiften/Elements/ErrorPayload.h"
-#include "Swiften/Avatars/CombinedAvatarProvider.h"
namespace Swift {
- class MUCRegistry;
- class AvatarStorage;
- class StanzaChannel;
- class VCardManager;
- class VCardUpdateAvatarManager;
- class VCardAvatarManager;
+ class JID;
class AvatarManager {
public:
- AvatarManager(VCardManager*, StanzaChannel*, AvatarStorage*, MUCRegistry* = NULL);
virtual ~AvatarManager();
- virtual boost::filesystem::path getAvatarPath(const JID&) const;
+ virtual boost::filesystem::path getAvatarPath(const JID&) const = 0;
- public:
boost::signal<void (const JID&)> onAvatarChanged;
-
- private:
- CombinedAvatarProvider combinedAvatarProvider;
- AvatarStorage* avatarStorage;
- VCardUpdateAvatarManager* vcardUpdateAvatarManager;
- VCardAvatarManager* vcardAvatarManager;
};
}
diff --git a/Swiften/Avatars/AvatarManagerImpl.cpp b/Swiften/Avatars/AvatarManagerImpl.cpp
new file mode 100644
index 0000000..384994b
--- /dev/null
+++ b/Swiften/Avatars/AvatarManagerImpl.cpp
@@ -0,0 +1,43 @@
+/*
+ * 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/AvatarManagerImpl.h"
+
+#include <boost/bind.hpp>
+
+#include "Swiften/Avatars/VCardUpdateAvatarManager.h"
+#include "Swiften/Avatars/VCardAvatarManager.h"
+#include "Swiften/Avatars/AvatarStorage.h"
+
+namespace Swift {
+
+AvatarManagerImpl::AvatarManagerImpl(VCardManager* vcardManager, StanzaChannel* stanzaChannel, AvatarStorage* avatarStorage, MUCRegistry* mucRegistry) : avatarStorage(avatarStorage) {
+ vcardUpdateAvatarManager = new VCardUpdateAvatarManager(vcardManager, stanzaChannel, avatarStorage, mucRegistry);
+ combinedAvatarProvider.addProvider(vcardUpdateAvatarManager);
+
+ vcardAvatarManager = new VCardAvatarManager(vcardManager, avatarStorage, mucRegistry);
+ combinedAvatarProvider.addProvider(vcardAvatarManager);
+
+ combinedAvatarProvider.onAvatarChanged.connect(boost::ref(onAvatarChanged));
+}
+
+AvatarManagerImpl::~AvatarManagerImpl() {
+ combinedAvatarProvider.removeProvider(vcardAvatarManager);
+ delete vcardAvatarManager;
+ combinedAvatarProvider.removeProvider(vcardUpdateAvatarManager);
+ delete vcardUpdateAvatarManager;
+}
+
+boost::filesystem::path AvatarManagerImpl::getAvatarPath(const JID& jid) const {
+ String hash = combinedAvatarProvider.getAvatarHash(jid);
+ if (!hash.isEmpty()) {
+ return avatarStorage->getAvatarPath(hash);
+ }
+ return boost::filesystem::path();
+}
+
+
+}
diff --git a/Swiften/Avatars/AvatarManagerImpl.h b/Swiften/Avatars/AvatarManagerImpl.h
new file mode 100644
index 0000000..f533160
--- /dev/null
+++ b/Swiften/Avatars/AvatarManagerImpl.h
@@ -0,0 +1,43 @@
+/*
+ * 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 <boost/filesystem.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
+#include <map>
+
+#include "Swiften/Avatars/AvatarManager.h"
+#include "Swiften/Base/boost_bsignals.h"
+#include "Swiften/JID/JID.h"
+#include "Swiften/Elements/Presence.h"
+#include "Swiften/Elements/VCard.h"
+#include "Swiften/Elements/ErrorPayload.h"
+#include "Swiften/Avatars/CombinedAvatarProvider.h"
+
+namespace Swift {
+ class MUCRegistry;
+ class AvatarStorage;
+ class StanzaChannel;
+ class VCardManager;
+ class VCardUpdateAvatarManager;
+ class VCardAvatarManager;
+
+ class AvatarManagerImpl : public AvatarManager {
+ public:
+ AvatarManagerImpl(VCardManager*, StanzaChannel*, AvatarStorage*, MUCRegistry* = NULL);
+ virtual ~AvatarManagerImpl();
+
+ virtual boost::filesystem::path getAvatarPath(const JID&) const;
+
+ private:
+ CombinedAvatarProvider combinedAvatarProvider;
+ AvatarStorage* avatarStorage;
+ VCardUpdateAvatarManager* vcardUpdateAvatarManager;
+ VCardAvatarManager* vcardAvatarManager;
+ };
+}
diff --git a/Swiften/Avatars/NullAvatarManager.h b/Swiften/Avatars/NullAvatarManager.h
new file mode 100644
index 0000000..7f3c646
--- /dev/null
+++ b/Swiften/Avatars/NullAvatarManager.h
@@ -0,0 +1,18 @@
+/*
+ * 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"
+
+namespace Swift {
+ class NullAvatarManager : public AvatarManager {
+ public:
+ virtual boost::filesystem::path getAvatarPath(const JID&) const {
+ return boost::filesystem::path();
+ }
+ };
+}
diff --git a/Swiften/Avatars/SConscript b/Swiften/Avatars/SConscript
index 60bee08..7922a51 100644
--- a/Swiften/Avatars/SConscript
+++ b/Swiften/Avatars/SConscript
@@ -5,6 +5,7 @@ objects = swiften_env.StaticObject([
"VCardUpdateAvatarManager.cpp",
"VCardAvatarManager.cpp",
"AvatarManager.cpp",
+ "AvatarManagerImpl.cpp",
"AvatarStorage.cpp",
"AvatarProvider.cpp",
"CombinedAvatarProvider.cpp",