diff options
Diffstat (limited to 'Swiften/Avatars')
-rw-r--r-- | Swiften/Avatars/AvatarFileStorage.cpp | 10 | ||||
-rw-r--r-- | Swiften/Avatars/AvatarFileStorage.h | 10 | ||||
-rw-r--r-- | Swiften/Avatars/AvatarManagerImpl.cpp | 8 | ||||
-rw-r--r-- | Swiften/Avatars/AvatarMemoryStorage.h | 16 | ||||
-rw-r--r-- | Swiften/Avatars/AvatarProvider.h | 4 | ||||
-rw-r--r-- | Swiften/Avatars/AvatarStorage.h | 10 | ||||
-rw-r--r-- | Swiften/Avatars/CombinedAvatarProvider.cpp | 16 | ||||
-rw-r--r-- | Swiften/Avatars/CombinedAvatarProvider.h | 4 | ||||
-rw-r--r-- | Swiften/Avatars/DummyAvatarManager.h | 2 | ||||
-rw-r--r-- | Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp | 18 | ||||
-rw-r--r-- | Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp | 14 | ||||
-rw-r--r-- | Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp | 8 | ||||
-rw-r--r-- | Swiften/Avatars/VCardAvatarManager.cpp | 4 | ||||
-rw-r--r-- | Swiften/Avatars/VCardAvatarManager.h | 2 | ||||
-rw-r--r-- | Swiften/Avatars/VCardUpdateAvatarManager.cpp | 14 | ||||
-rw-r--r-- | Swiften/Avatars/VCardUpdateAvatarManager.h | 6 |
16 files changed, 73 insertions, 73 deletions
diff --git a/Swiften/Avatars/AvatarFileStorage.cpp b/Swiften/Avatars/AvatarFileStorage.cpp index f76adee..046ac16 100644 --- a/Swiften/Avatars/AvatarFileStorage.cpp +++ b/Swiften/Avatars/AvatarFileStorage.cpp @@ -14,11 +14,11 @@ namespace Swift { AvatarFileStorage::AvatarFileStorage(const boost::filesystem::path& path) : path_(path) { } -bool AvatarFileStorage::hasAvatar(const String& hash) const { +bool AvatarFileStorage::hasAvatar(const std::string& hash) const { return boost::filesystem::exists(getAvatarPath(hash)); } -void AvatarFileStorage::addAvatar(const String& hash, const ByteArray& avatar) { +void AvatarFileStorage::addAvatar(const std::string& hash, const ByteArray& avatar) { boost::filesystem::path avatarPath = getAvatarPath(hash); if (!boost::filesystem::exists(avatarPath.parent_path())) { try { @@ -33,11 +33,11 @@ void AvatarFileStorage::addAvatar(const String& hash, const ByteArray& avatar) { file.close(); } -boost::filesystem::path AvatarFileStorage::getAvatarPath(const String& hash) const { - return path_ / hash.getUTF8String(); +boost::filesystem::path AvatarFileStorage::getAvatarPath(const std::string& hash) const { + return path_ / hash; } -ByteArray AvatarFileStorage::getAvatar(const String& hash) const { +ByteArray AvatarFileStorage::getAvatar(const std::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 5ade779..e803430 100644 --- a/Swiften/Avatars/AvatarFileStorage.h +++ b/Swiften/Avatars/AvatarFileStorage.h @@ -9,7 +9,7 @@ #include <map> #include <boost/filesystem.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/Avatars/AvatarStorage.h" @@ -18,11 +18,11 @@ namespace Swift { public: AvatarFileStorage(const boost::filesystem::path& path); - virtual bool hasAvatar(const String& hash) const; - virtual void addAvatar(const String& hash, const ByteArray& avatar); - virtual ByteArray getAvatar(const String& hash) const; + virtual bool hasAvatar(const std::string& hash) const; + virtual void addAvatar(const std::string& hash, const ByteArray& avatar); + virtual ByteArray getAvatar(const std::string& hash) const; - virtual boost::filesystem::path getAvatarPath(const String& hash) const; + virtual boost::filesystem::path getAvatarPath(const std::string& hash) const; private: boost::filesystem::path path_; diff --git a/Swiften/Avatars/AvatarManagerImpl.cpp b/Swiften/Avatars/AvatarManagerImpl.cpp index 9813aed..6b77f8d 100644 --- a/Swiften/Avatars/AvatarManagerImpl.cpp +++ b/Swiften/Avatars/AvatarManagerImpl.cpp @@ -33,16 +33,16 @@ AvatarManagerImpl::~AvatarManagerImpl() { } boost::filesystem::path AvatarManagerImpl::getAvatarPath(const JID& jid) const { - String hash = combinedAvatarProvider.getAvatarHash(jid); - if (!hash.isEmpty()) { + std::string hash = combinedAvatarProvider.getAvatarHash(jid); + if (!hash.empty()) { return avatarStorage->getAvatarPath(hash); } return boost::filesystem::path(); } ByteArray AvatarManagerImpl::getAvatar(const JID& jid) const { - String hash = combinedAvatarProvider.getAvatarHash(jid); - if (!hash.isEmpty()) { + std::string hash = combinedAvatarProvider.getAvatarHash(jid); + if (!hash.empty()) { return avatarStorage->getAvatar(hash); } return ByteArray(); diff --git a/Swiften/Avatars/AvatarMemoryStorage.h b/Swiften/Avatars/AvatarMemoryStorage.h index 6f1ba49..3fa770a 100644 --- a/Swiften/Avatars/AvatarMemoryStorage.h +++ b/Swiften/Avatars/AvatarMemoryStorage.h @@ -8,25 +8,25 @@ #include <map> -#include "Swiften/Base/String.h" +#include <string> #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); + virtual bool hasAvatar(const std::string& hash) const { return avatars.find(hash) != avatars.end(); } + virtual void addAvatar(const std::string& hash, const ByteArray& avatar) { avatars[hash] = avatar; } + virtual ByteArray getAvatar(const std::string& hash) const { + std::map<std::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("/avatars") / hash.getUTF8String(); + virtual boost::filesystem::path getAvatarPath(const std::string& hash) const { + return boost::filesystem::path("/avatars") / hash; } private: - std::map<String, ByteArray> avatars; + std::map<std::string, ByteArray> avatars; }; } diff --git a/Swiften/Avatars/AvatarProvider.h b/Swiften/Avatars/AvatarProvider.h index b953ad3..0f66904 100644 --- a/Swiften/Avatars/AvatarProvider.h +++ b/Swiften/Avatars/AvatarProvider.h @@ -7,7 +7,7 @@ #pragma once #include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class JID; @@ -16,7 +16,7 @@ namespace Swift { public: virtual ~AvatarProvider(); - virtual String getAvatarHash(const JID&) const = 0; + virtual std::string getAvatarHash(const JID&) const = 0; boost::signal<void (const JID&)> onAvatarChanged; }; diff --git a/Swiften/Avatars/AvatarStorage.h b/Swiften/Avatars/AvatarStorage.h index d699f40..826a648 100644 --- a/Swiften/Avatars/AvatarStorage.h +++ b/Swiften/Avatars/AvatarStorage.h @@ -9,17 +9,17 @@ #include <boost/filesystem.hpp> namespace Swift { - class String; + class ByteArray; class AvatarStorage { public: virtual ~AvatarStorage(); - 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; + virtual bool hasAvatar(const std::string& hash) const = 0; + virtual void addAvatar(const std::string& hash, const ByteArray& avatar) = 0; + virtual ByteArray getAvatar(const std::string& hash) const = 0; + virtual boost::filesystem::path getAvatarPath(const std::string& hash) const = 0; }; } diff --git a/Swiften/Avatars/CombinedAvatarProvider.cpp b/Swiften/Avatars/CombinedAvatarProvider.cpp index 4f0b04a..6ac31e3 100644 --- a/Swiften/Avatars/CombinedAvatarProvider.cpp +++ b/Swiften/Avatars/CombinedAvatarProvider.cpp @@ -11,14 +11,14 @@ namespace Swift { -String CombinedAvatarProvider::getAvatarHash(const JID& jid) const { +std::string CombinedAvatarProvider::getAvatarHash(const JID& jid) const { for (size_t i = 0; i < providers.size(); ++i) { - String hash = providers[i]->getAvatarHash(jid); - if (!hash.isEmpty()) { + std::string hash = providers[i]->getAvatarHash(jid); + if (!hash.empty()) { return hash; } } - return String(); + return std::string(); } void CombinedAvatarProvider::addProvider(AvatarProvider* provider) { @@ -35,11 +35,11 @@ void CombinedAvatarProvider::removeProvider(AvatarProvider* provider) { } void CombinedAvatarProvider::handleAvatarChanged(const JID& jid) { - String hash = getAvatarHash(jid); - std::map<JID, String>::iterator i = avatars.find(jid); + std::string hash = getAvatarHash(jid); + std::map<JID, std::string>::iterator i = avatars.find(jid); if (i != avatars.end()) { if (i->second != hash) { - if (hash.isEmpty()) { + if (hash.empty()) { avatars.erase(i); } else { @@ -48,7 +48,7 @@ void CombinedAvatarProvider::handleAvatarChanged(const JID& jid) { onAvatarChanged(jid); } } - else if (!hash.isEmpty()) { + else if (!hash.empty()) { avatars.insert(std::make_pair(jid, hash)); onAvatarChanged(jid); } diff --git a/Swiften/Avatars/CombinedAvatarProvider.h b/Swiften/Avatars/CombinedAvatarProvider.h index fbd6ce7..9c83732 100644 --- a/Swiften/Avatars/CombinedAvatarProvider.h +++ b/Swiften/Avatars/CombinedAvatarProvider.h @@ -15,7 +15,7 @@ namespace Swift { class CombinedAvatarProvider : public AvatarProvider { public: - virtual String getAvatarHash(const JID&) const; + virtual std::string getAvatarHash(const JID&) const; void addProvider(AvatarProvider*); void removeProvider(AvatarProvider*); @@ -25,6 +25,6 @@ namespace Swift { private: std::vector<AvatarProvider*> providers; - std::map<JID, String> avatars; + std::map<JID, std::string> avatars; }; } diff --git a/Swiften/Avatars/DummyAvatarManager.h b/Swiften/Avatars/DummyAvatarManager.h index 12bbe42..e73c61e 100644 --- a/Swiften/Avatars/DummyAvatarManager.h +++ b/Swiften/Avatars/DummyAvatarManager.h @@ -15,7 +15,7 @@ namespace Swift { class DummyAvatarManager : public AvatarManager { public: virtual boost::filesystem::path getAvatarPath(const JID& j) const { - return boost::filesystem::path("/avatars") / j.toString().getUTF8String(); + return boost::filesystem::path("/avatars") / j.toString(); } virtual ByteArray getAvatar(const JID& jid) const { diff --git a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp index ad3a0f1..6153d29 100644 --- a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp +++ b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp @@ -9,7 +9,7 @@ #include <boost/bind.hpp> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Avatars/CombinedAvatarProvider.h" using namespace Swift; @@ -47,7 +47,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture { void testGetAvatarWithNoAvatarProviderReturnsEmpty() { std::auto_ptr<CombinedAvatarProvider> testling(createProvider()); - CPPUNIT_ASSERT(testling->getAvatarHash(user1).isEmpty()); + CPPUNIT_ASSERT(testling->getAvatarHash(user1).empty()); } void testGetAvatarWithSingleAvatarProvider() { @@ -168,26 +168,26 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture { private: struct DummyAvatarProvider : public AvatarProvider { - String getAvatarHash(const JID& jid) const { - std::map<JID, String>::const_iterator i = avatars.find(jid); + std::string getAvatarHash(const JID& jid) const { + std::map<JID, std::string>::const_iterator i = avatars.find(jid); if (i != avatars.end()) { return i->second; } else { - return String(); + return std::string(); } } - std::map<JID, String> avatars; + std::map<JID, std::string> avatars; }; DummyAvatarProvider* avatarProvider1; DummyAvatarProvider* avatarProvider2; JID user1; JID user2; - String avatarHash1; - String avatarHash2; - String avatarHash3; + std::string avatarHash1; + std::string avatarHash2; + std::string avatarHash3; std::vector<JID> changes; }; diff --git a/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp index 8cb9ccb..be5eaea 100644 --- a/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp +++ b/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp @@ -62,7 +62,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { storeVCardWithPhoto(user1.toBare(), avatar1); avatarStorage->addAvatar(avatar1Hash, avatar1); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); CPPUNIT_ASSERT_EQUAL(avatar1Hash, result); } @@ -71,16 +71,16 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { std::auto_ptr<VCardAvatarManager> testling = createManager(); storeEmptyVCard(user1.toBare()); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); - CPPUNIT_ASSERT_EQUAL(String(), result); + CPPUNIT_ASSERT_EQUAL(std::string(), result); } void testGetAvatarHashUnknownAvatarKnownVCardStoresAvatar() { std::auto_ptr<VCardAvatarManager> testling = createManager(); storeVCardWithPhoto(user1.toBare(), avatar1); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); CPPUNIT_ASSERT_EQUAL(avatar1Hash, result); CPPUNIT_ASSERT(avatarStorage->hasAvatar(avatar1Hash)); @@ -90,9 +90,9 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { void testGetAvatarHashUnknownAvatarUnknownVCard() { std::auto_ptr<VCardAvatarManager> testling = createManager(); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); - CPPUNIT_ASSERT_EQUAL(String(), result); + CPPUNIT_ASSERT_EQUAL(std::string(), result); } void testVCardUpdateTriggersUpdate() { @@ -145,7 +145,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { VCardManager* vcardManager; VCardMemoryStorage* vcardStorage; ByteArray avatar1; - String avatar1Hash; + std::string avatar1Hash; std::vector<JID> changes; JID user1; JID user2; diff --git a/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp index a928ced..cde4a45 100644 --- a/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp +++ b/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp @@ -113,7 +113,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { stanzaChannel->onIQReceived(createVCardResult(ByteArray())); CPPUNIT_ASSERT(!avatarStorage->hasAvatar(Hexify::hexify(SHA1::getHash(ByteArray())))); - CPPUNIT_ASSERT_EQUAL(String(), testling->getAvatarHash(JID("foo@bar.com"))); + CPPUNIT_ASSERT_EQUAL(std::string(), testling->getAvatarHash(JID("foo@bar.com"))); } void testStanzaChannelReset_ClearsHash() { @@ -128,7 +128,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); CPPUNIT_ASSERT_EQUAL(user1.toBare(), changes[0]); - CPPUNIT_ASSERT_EQUAL(String(""), testling->getAvatarHash(user1.toBare())); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling->getAvatarHash(user1.toBare())); } void testStanzaChannelReset_ReceiveHashAfterResetUpdatesHash() { @@ -154,7 +154,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { return result; } - boost::shared_ptr<Presence> createPresenceWithPhotoHash(const JID& jid, const String& hash) { + boost::shared_ptr<Presence> createPresenceWithPhotoHash(const JID& jid, const std::string& hash) { boost::shared_ptr<Presence> presence(new Presence()); presence->setFrom(jid); presence->addPayload(boost::shared_ptr<VCardUpdate>(new VCardUpdate(hash))); @@ -187,7 +187,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { VCardManager* vcardManager; VCardMemoryStorage* vcardStorage; ByteArray avatar1; - String avatar1Hash; + std::string avatar1Hash; std::vector<JID> changes; JID user1; JID user2; diff --git a/Swiften/Avatars/VCardAvatarManager.cpp b/Swiften/Avatars/VCardAvatarManager.cpp index 244a73e..ce732db 100644 --- a/Swiften/Avatars/VCardAvatarManager.cpp +++ b/Swiften/Avatars/VCardAvatarManager.cpp @@ -28,10 +28,10 @@ void VCardAvatarManager::handleVCardChanged(const JID& from) { onAvatarChanged(from); } -String VCardAvatarManager::getAvatarHash(const JID& jid) const { +std::string VCardAvatarManager::getAvatarHash(const JID& jid) const { VCard::ref vCard = vcardManager_->getVCard(getAvatarJID(jid)); if (vCard && !vCard->getPhoto().isEmpty()) { - String hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); + std::string hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); if (!avatarStorage_->hasAvatar(hash)) { avatarStorage_->addAvatar(hash, vCard->getPhoto()); } diff --git a/Swiften/Avatars/VCardAvatarManager.h b/Swiften/Avatars/VCardAvatarManager.h index 069f938..3f99dad 100644 --- a/Swiften/Avatars/VCardAvatarManager.h +++ b/Swiften/Avatars/VCardAvatarManager.h @@ -21,7 +21,7 @@ namespace Swift { public: VCardAvatarManager(VCardManager*, AvatarStorage*, MUCRegistry* = NULL); - String getAvatarHash(const JID&) const; + std::string getAvatarHash(const JID&) const; private: void handleVCardChanged(const JID& from); diff --git a/Swiften/Avatars/VCardUpdateAvatarManager.cpp b/Swiften/Avatars/VCardUpdateAvatarManager.cpp index 879846e..08d026b 100644 --- a/Swiften/Avatars/VCardUpdateAvatarManager.cpp +++ b/Swiften/Avatars/VCardUpdateAvatarManager.cpp @@ -52,7 +52,7 @@ void VCardUpdateAvatarManager::handleVCardChanged(const JID& from, VCard::ref vC setAvatarHash(from, ""); } else { - String hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); + std::string hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); if (!avatarStorage_->hasAvatar(hash)) { avatarStorage_->addAvatar(hash, vCard->getPhoto()); } @@ -60,21 +60,21 @@ void VCardUpdateAvatarManager::handleVCardChanged(const JID& from, VCard::ref vC } } -void VCardUpdateAvatarManager::setAvatarHash(const JID& from, const String& hash) { +void VCardUpdateAvatarManager::setAvatarHash(const JID& from, const std::string& hash) { avatarHashes_[from] = hash; onAvatarChanged(from); } /* void VCardUpdateAvatarManager::setAvatar(const JID& jid, const ByteArray& avatar) { - String hash = Hexify::hexify(SHA1::getHash(avatar)); + std::string hash = Hexify::hexify(SHA1::getHash(avatar)); avatarStorage_->addAvatar(hash, avatar); setAvatarHash(getAvatarJID(jid), hash); } */ -String VCardUpdateAvatarManager::getAvatarHash(const JID& jid) const { - std::map<JID, String>::const_iterator i = avatarHashes_.find(getAvatarJID(jid)); +std::string VCardUpdateAvatarManager::getAvatarHash(const JID& jid) const { + std::map<JID, std::string>::const_iterator i = avatarHashes_.find(getAvatarJID(jid)); if (i != avatarHashes_.end()) { return i->second; } @@ -90,9 +90,9 @@ JID VCardUpdateAvatarManager::getAvatarJID(const JID& jid) const { void VCardUpdateAvatarManager::handleStanzaChannelAvailableChanged(bool available) { if (available) { - std::map<JID, String> oldAvatarHashes; + std::map<JID, std::string> oldAvatarHashes; avatarHashes_.swap(oldAvatarHashes); - for(std::map<JID, String>::const_iterator i = oldAvatarHashes.begin(); i != oldAvatarHashes.end(); ++i) { + for(std::map<JID, std::string>::const_iterator i = oldAvatarHashes.begin(); i != oldAvatarHashes.end(); ++i) { onAvatarChanged(i->first); } } diff --git a/Swiften/Avatars/VCardUpdateAvatarManager.h b/Swiften/Avatars/VCardUpdateAvatarManager.h index 8827ab7..1f03898 100644 --- a/Swiften/Avatars/VCardUpdateAvatarManager.h +++ b/Swiften/Avatars/VCardUpdateAvatarManager.h @@ -25,13 +25,13 @@ namespace Swift { public: VCardUpdateAvatarManager(VCardManager*, StanzaChannel*, AvatarStorage*, MUCRegistry* = NULL); - String getAvatarHash(const JID&) const; + std::string getAvatarHash(const JID&) const; private: void handlePresenceReceived(boost::shared_ptr<Presence>); void handleStanzaChannelAvailableChanged(bool); void handleVCardChanged(const JID& from, VCard::ref); - void setAvatarHash(const JID& from, const String& hash); + void setAvatarHash(const JID& from, const std::string& hash); JID getAvatarJID(const JID& o) const; private: @@ -39,6 +39,6 @@ namespace Swift { StanzaChannel* stanzaChannel_; AvatarStorage* avatarStorage_; MUCRegistry* mucRegistry_; - std::map<JID, String> avatarHashes_; + std::map<JID, std::string> avatarHashes_; }; } |