diff options
Diffstat (limited to 'Swiften/VCards/VCardManager.cpp')
-rw-r--r-- | Swiften/VCards/VCardManager.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Swiften/VCards/VCardManager.cpp b/Swiften/VCards/VCardManager.cpp index 52447a1..5a65dcd 100644 --- a/Swiften/VCards/VCardManager.cpp +++ b/Swiften/VCards/VCardManager.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2014 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -9,4 +9,5 @@ #include <boost/bind.hpp> +#include <Swiften/Base/Log.h> #include <Swiften/JID/JID.h> #include <Swiften/VCards/VCardStorage.h> @@ -26,7 +27,9 @@ VCard::ref VCardManager::getVCard(const JID& jid) const { } -VCard::ref VCardManager::getVCardAndRequestWhenNeeded(const JID& jid) { +VCard::ref VCardManager::getVCardAndRequestWhenNeeded(const JID& jid, const boost::posix_time::time_duration& allowedAge) { VCard::ref vcard = storage->getVCard(jid); - if (!vcard) { + boost::posix_time::ptime vcardFetchedTime = storage->getVCardWriteTime(jid); + bool vcardTooOld = vcard && (vcardFetchedTime.is_special() || ((boost::posix_time::second_clock::universal_time() - vcardFetchedTime) > allowedAge)); + if (!vcard || vcardTooOld) { requestVCard(jid); } |