diff options
author | Tobias Markmann <tm@ayena.de> | 2013-02-25 23:20:59 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2013-03-04 15:18:47 (GMT) |
commit | 836925a5cdc7017da7fb84416c803e652b48e399 (patch) | |
tree | 2f659c2bc3e6db70cbc09e0cb13953c1a8ccd8e4 /Swift/Controllers/Chat | |
parent | ffbd6feb875a9d50ec834fd6dfe967528697a9ff (diff) | |
download | swift-contrib-836925a5cdc7017da7fb84416c803e652b48e399.zip swift-contrib-836925a5cdc7017da7fb84416c803e652b48e399.tar.bz2 |
Adding support for idle time.
Change-Id: I1b14edb97a0c87431ec377b084362e9761caded9
License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index edd2e3b..2d2d941 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -31,6 +31,7 @@ #include <Swift/Controllers/UIEvents/ShowWhiteboardUIEvent.h> #include <Swiften/Elements/DeliveryReceipt.h> #include <Swiften/Elements/DeliveryReceiptRequest.h> +#include <Swiften/Elements/Idle.h> #include <Swift/Controllers/SettingConstants.h> #include <Swift/Controllers/Highlighter.h> #include <Swiften/Base/Log.h> @@ -62,6 +63,10 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ startMessage = str(format(QT_TRANSLATE_NOOP("", "Starting chat with %1% - %2%")) % nick % contact.toBare().toString()); theirPresence = contact.isBare() ? presenceOracle->getHighestPriorityPresence(contact.toBare()) : presenceOracle->getLastPresence(contact); } + Idle::ref idle; + if (theirPresence && (idle = theirPresence->getPayload<Idle>())) { + startMessage += QT_TRANSLATE_NOOP("", ", who has been idle since ") + boost::posix_time::to_simple_string(idle->getSince()); + } startMessage += ": " + statusShowTypeToFriendlyName(theirPresence ? theirPresence->getShow() : StatusShow::None); if (theirPresence && !theirPresence->getStatus().empty()) { startMessage += " (" + theirPresence->getStatus() + ")"; @@ -335,6 +340,11 @@ std::string ChatController::getStatusChangeString(boost::shared_ptr<Presence> pr response = QT_TRANSLATE_NOOP("", "%1% is now busy"); } } + Idle::ref idle; + if ((idle = presence->getPayload<Idle>())) { + response += QT_TRANSLATE_NOOP("", " and has been idle since ") + boost::posix_time::to_simple_string(idle->getSince()); + } + if (!response.empty()) { response = str(format(response) % nick); } |