summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/VCards')
-rw-r--r--Swiften/VCards/UnitTest/VCardManagerTest.cpp8
-rw-r--r--Swiften/VCards/VCardMemoryStorage.h4
-rw-r--r--Swiften/VCards/VCardStorage.cpp9
-rw-r--r--Swiften/VCards/VCardStorage.h7
4 files changed, 20 insertions, 8 deletions
diff --git a/Swiften/VCards/UnitTest/VCardManagerTest.cpp b/Swiften/VCards/UnitTest/VCardManagerTest.cpp
index eecec7b..9f1c8bb 100644
--- a/Swiften/VCards/UnitTest/VCardManagerTest.cpp
+++ b/Swiften/VCards/UnitTest/VCardManagerTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -16,6 +16,8 @@
#include <Swiften/VCards/VCardMemoryStorage.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Client/DummyStanzaChannel.h>
+#include <Swiften/Crypto/CryptoProvider.h>
+#include <Swiften/Crypto/PlatformCryptoProvider.h>
using namespace Swift;
@@ -36,9 +38,10 @@ class VCardManagerTest : public CppUnit::TestFixture {
public:
void setUp() {
ownJID = JID("baz@fum.com/dum");
+ crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
stanzaChannel = new DummyStanzaChannel();
iqRouter = new IQRouter(stanzaChannel);
- vcardStorage = new VCardMemoryStorage();
+ vcardStorage = new VCardMemoryStorage(crypto.get());
}
void tearDown() {
@@ -201,6 +204,7 @@ class VCardManagerTest : public CppUnit::TestFixture {
VCardMemoryStorage* vcardStorage;
std::vector< std::pair<JID, VCard::ref> > changes;
std::vector<VCard::ref> ownChanges;
+ boost::shared_ptr<CryptoProvider> crypto;
};
CPPUNIT_TEST_SUITE_REGISTRATION(VCardManagerTest);
diff --git a/Swiften/VCards/VCardMemoryStorage.h b/Swiften/VCards/VCardMemoryStorage.h
index ade9c89..86ae1b2 100644
--- a/Swiften/VCards/VCardMemoryStorage.h
+++ b/Swiften/VCards/VCardMemoryStorage.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -15,7 +15,7 @@
namespace Swift {
class VCardMemoryStorage : public VCardStorage {
public:
- VCardMemoryStorage() {}
+ VCardMemoryStorage(CryptoProvider* crypto) : VCardStorage(crypto) {}
virtual VCard::ref getVCard(const JID& jid) const {
VCardMap::const_iterator i = vcards.find(jid);
diff --git a/Swiften/VCards/VCardStorage.cpp b/Swiften/VCards/VCardStorage.cpp
index 900f1e5..fefea83 100644
--- a/Swiften/VCards/VCardStorage.cpp
+++ b/Swiften/VCards/VCardStorage.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -7,17 +7,20 @@
#include <Swiften/VCards/VCardStorage.h>
#include <Swiften/StringCodecs/Hexify.h>
-#include <Swiften/StringCodecs/SHA1.h>
+#include <Swiften/Crypto/CryptoProvider.h>
namespace Swift {
+VCardStorage::VCardStorage(CryptoProvider* crypto) : crypto(crypto) {
+}
+
VCardStorage::~VCardStorage() {
}
std::string VCardStorage::getPhotoHash(const JID& jid) const {
VCard::ref vCard = getVCard(jid);
if (vCard && !vCard->getPhoto().empty()) {
- return Hexify::hexify(SHA1::getHash(vCard->getPhoto()));
+ return Hexify::hexify(crypto->getSHA1Hash(vCard->getPhoto()));
}
else {
return "";
diff --git a/Swiften/VCards/VCardStorage.h b/Swiften/VCards/VCardStorage.h
index 5fba915..924204c 100644
--- a/Swiften/VCards/VCardStorage.h
+++ b/Swiften/VCards/VCardStorage.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -14,14 +14,19 @@
namespace Swift {
class JID;
+ class CryptoProvider;
class SWIFTEN_API VCardStorage {
public:
+ VCardStorage(CryptoProvider*);
virtual ~VCardStorage();
virtual VCard::ref getVCard(const JID& jid) const = 0;
virtual void setVCard(const JID&, VCard::ref) = 0;
virtual std::string getPhotoHash(const JID&) const;
+
+ private:
+ CryptoProvider* crypto;
};
}