diff options
Diffstat (limited to 'Swiften/Elements/Stanza.cpp')
-rw-r--r-- | Swiften/Elements/Stanza.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Swiften/Elements/Stanza.cpp b/Swiften/Elements/Stanza.cpp index dd6021d..d15d778 100644 --- a/Swiften/Elements/Stanza.cpp +++ b/Swiften/Elements/Stanza.cpp @@ -5,6 +5,7 @@ */ #include "Swiften/Elements/Stanza.h" +#include "Swiften/Elements/Delay.h" #include <typeinfo> @@ -33,5 +34,20 @@ boost::shared_ptr<Payload> Stanza::getPayloadOfSameType(boost::shared_ptr<Payloa return boost::shared_ptr<Payload>(); } +boost::optional<boost::posix_time::ptime> Stanza::getTimestamp() const { + boost::shared_ptr<Delay> delay = getPayload<Delay>(); + return delay ? delay->getStamp() : boost::optional<boost::posix_time::ptime>(); +} + +boost::optional<boost::posix_time::ptime> Stanza::getTimestampFrom(const JID& jid) const { + std::vector< boost::shared_ptr<Delay> > delays = getPayloads<Delay>(); + for (size_t i = 0; i < delays.size(); ++i) { + if (delays[i]->getFrom() == jid) { + return delays[i]->getStamp(); + } + } + return getTimestamp(); +} + } |